From: Sascha Schumann Date: Tue, 9 Jan 2001 16:45:19 +0000 (+0000) Subject: Avoid possible memory leak in the URL scanner, if the connection is X-Git-Tag: php-4.0.5RC1~646 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7eb8469679bf44b200c6f55ac59cb8592b9638f4;p=php Avoid possible memory leak in the URL scanner, if the connection is interrupted during writing the output. --- diff --git a/ext/standard/output.c b/ext/standard/output.c index 88f74b57f0..970917558d 100644 --- a/ext/standard/output.c +++ b/ext/standard/output.c @@ -361,10 +361,6 @@ static int php_ub_body_write_no_header(const char *str, uint str_length) result = OG(php_header_write)(str, str_length); - if (newstr) { - free(newstr); - } - if (OG(implicit_flush)) { sapi_flush(); } diff --git a/ext/standard/url_scanner_ex.c b/ext/standard/url_scanner_ex.c index e7becb5c3c..766c85c90c 100644 --- a/ext/standard/url_scanner_ex.c +++ b/ext/standard/url_scanner_ex.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.5 on Fri Dec 22 23:45:29 2000 */ +/* Generated by re2c 0.5 on Tue Jan 9 17:13:20 2001 */ #line 1 "/home/sas/src/php4/ext/standard/url_scanner_ex.re" /* +----------------------------------------------------------------------+ @@ -691,14 +691,9 @@ char *url_adapt_ext(const char *src, size_t srclen, const char *name, const char mainloop(ctx, src, srclen); *newlen = ctx->result.len; - if (ctx->result.len == 0) { - return strdup(""); - } smart_str_0(&ctx->result); - ret = malloc(ctx->result.len + 1); - memcpy(ret, ctx->result.c, ctx->result.len + 1); ctx->result.len = 0; - return ret; + return ctx->result.c; } PHP_RINIT_FUNCTION(url_scanner) diff --git a/ext/standard/url_scanner_ex.re b/ext/standard/url_scanner_ex.re index 3060658097..3eb7a56c08 100644 --- a/ext/standard/url_scanner_ex.re +++ b/ext/standard/url_scanner_ex.re @@ -334,14 +334,9 @@ char *url_adapt_ext(const char *src, size_t srclen, const char *name, const char mainloop(ctx, src, srclen); *newlen = ctx->result.len; - if (ctx->result.len == 0) { - return strdup(""); - } smart_str_0(&ctx->result); - ret = malloc(ctx->result.len + 1); - memcpy(ret, ctx->result.c, ctx->result.len + 1); ctx->result.len = 0; - return ret; + return ctx->result.c; } PHP_RINIT_FUNCTION(url_scanner) diff --git a/main/output.c b/main/output.c index 88f74b57f0..970917558d 100644 --- a/main/output.c +++ b/main/output.c @@ -361,10 +361,6 @@ static int php_ub_body_write_no_header(const char *str, uint str_length) result = OG(php_header_write)(str, str_length); - if (newstr) { - free(newstr); - } - if (OG(implicit_flush)) { sapi_flush(); }