Avoid possible memory leak in the URL scanner, if the connection is

interrupted during writing the output.
This commit is contained in:
Sascha Schumann 2001-01-09 16:45:19 +00:00
parent 8d5d20500b
commit 7eb8469679
4 changed files with 3 additions and 21 deletions

View file

@ -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); result = OG(php_header_write)(str, str_length);
if (newstr) {
free(newstr);
}
if (OG(implicit_flush)) { if (OG(implicit_flush)) {
sapi_flush(); sapi_flush();
} }

View file

@ -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" #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); mainloop(ctx, src, srclen);
*newlen = ctx->result.len; *newlen = ctx->result.len;
if (ctx->result.len == 0) {
return strdup("");
}
smart_str_0(&ctx->result); smart_str_0(&ctx->result);
ret = malloc(ctx->result.len + 1);
memcpy(ret, ctx->result.c, ctx->result.len + 1);
ctx->result.len = 0; ctx->result.len = 0;
return ret; return ctx->result.c;
} }
PHP_RINIT_FUNCTION(url_scanner) PHP_RINIT_FUNCTION(url_scanner)

View file

@ -334,14 +334,9 @@ char *url_adapt_ext(const char *src, size_t srclen, const char *name, const char
mainloop(ctx, src, srclen); mainloop(ctx, src, srclen);
*newlen = ctx->result.len; *newlen = ctx->result.len;
if (ctx->result.len == 0) {
return strdup("");
}
smart_str_0(&ctx->result); smart_str_0(&ctx->result);
ret = malloc(ctx->result.len + 1);
memcpy(ret, ctx->result.c, ctx->result.len + 1);
ctx->result.len = 0; ctx->result.len = 0;
return ret; return ctx->result.c;
} }
PHP_RINIT_FUNCTION(url_scanner) PHP_RINIT_FUNCTION(url_scanner)

View file

@ -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); result = OG(php_header_write)(str, str_length);
if (newstr) {
free(newstr);
}
if (OG(implicit_flush)) { if (OG(implicit_flush)) {
sapi_flush(); sapi_flush();
} }