]> granicus.if.org Git - php/commitdiff
-keep mimetype until sapi deactivation
authorMarcus Boerger <helly@php.net>
Mon, 5 Aug 2002 18:32:05 +0000 (18:32 +0000)
committerMarcus Boerger <helly@php.net>
Mon, 5 Aug 2002 18:32:05 +0000 (18:32 +0000)
-move NULL check for sapi_apply_default_charset to proper position.

main/SAPI.c

index f03b858f56ea45bfefd6c05a9e14ac9162fcaa2c..054d35dce242e58b70177dcc50425958d1a8c447 100644 (file)
@@ -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);
 }