From: Marcus Boerger Date: Mon, 5 Aug 2002 18:32:05 +0000 (+0000) Subject: -keep mimetype until sapi deactivation X-Git-Tag: dev~16 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=abc7041ca2d964214585f81369e2ee36d7a7b9dc;p=php -keep mimetype until sapi deactivation -move NULL check for sapi_apply_default_charset to proper position. --- diff --git a/main/SAPI.c b/main/SAPI.c index f03b858f56..054d35dce2 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -260,16 +260,16 @@ SAPI_API size_t sapi_apply_default_charset(char **mimetype, size_t len TSRMLS_DC size_t newlen; charset = SG(default_charset) ? SG(default_charset) : SAPI_DEFAULT_CHARSET; - if (*charset && strncmp(*mimetype, "text/", 5) == 0 && strstr(*mimetype, "charset=") == NULL) { - newlen = len + (sizeof(";charset=")-1) + strlen(charset); - newtype = emalloc(newlen + 1); - PHP_STRLCPY(newtype, *mimetype, newlen + 1, len); - strlcat(newtype, ";charset=", newlen + 1); - if (*mimetype != NULL) { + if (*mimetype != NULL) { + if (*charset && strncmp(*mimetype, "text/", 5) == 0 && strstr(*mimetype, "charset=") == NULL) { + newlen = len + (sizeof(";charset=")-1) + strlen(charset); + newtype = emalloc(newlen + 1); + PHP_STRLCPY(newtype, *mimetype, newlen + 1, len); + strlcat(newtype, ";charset=", newlen + 1); efree(*mimetype); + *mimetype = newtype; + return newlen; } - *mimetype = newtype; - return newlen; } return 0; } @@ -344,10 +344,6 @@ static void sapi_send_headers_free(TSRMLS_D) efree(SG(sapi_headers).http_status_line); SG(sapi_headers).http_status_line = NULL; } - if (SG(sapi_headers).mimetype) { - efree(SG(sapi_headers).mimetype); - SG(sapi_headers).mimetype = NULL; - } } SAPI_API void sapi_deactivate(TSRMLS_D) @@ -374,6 +370,10 @@ SAPI_API void sapi_deactivate(TSRMLS_D) if (SG(rfc1867_uploaded_files)) { destroy_uploaded_files_hash(TSRMLS_C); } + if (SG(sapi_headers).mimetype) { + efree(SG(sapi_headers).mimetype); + SG(sapi_headers).mimetype = NULL; + } sapi_send_headers_free(TSRMLS_C); }