]> granicus.if.org Git - php/commitdiff
fixed a bug which causes crash when charset is not set.
authorRui Hirokawa <hirokawa@php.net>
Fri, 12 Apr 2002 15:07:48 +0000 (15:07 +0000)
committerRui Hirokawa <hirokawa@php.net>
Fri, 12 Apr 2002 15:07:48 +0000 (15:07 +0000)
ext/mbstring/mbstring.c

index cc019e1e12d91fcbf5985dab07a794184818df86..7868a8b073528c3125a8afb02ab973d02efc96fa 100644 (file)
@@ -1476,14 +1476,16 @@ PHP_FUNCTION(mb_output_handler)
                if (SG(sapi_headers).send_default_content_type ) {
                        mimetype = SG(default_mimetype) ? SG(default_mimetype) : SAPI_DEFAULT_MIMETYPE;
                        charset = mbfl_no2preferred_mime_name(encoding);
-                       len = (sizeof ("Content-Type:")-1) + strlen(mimetype) + (sizeof (";charset=")-1) + strlen(charset) + 1;
-                       p = emalloc(len);
-                       strcpy(p, "Content-Type:");
-                       strcat(p, mimetype);
-                       strcat(p, ";charset=");
-                       strcat(p, charset);
-                       if (sapi_add_header(p, len, 0) != FAILURE)
-                               SG(sapi_headers).send_default_content_type = 0;
+                       if (charset) {
+                               len = (sizeof ("Content-Type:")-1) + strlen(mimetype) + (sizeof (";charset=")-1) + strlen(charset) + 1;
+                               p = emalloc(len);
+                               strcpy(p, "Content-Type:");
+                               strcat(p, mimetype);
+                               strcat(p, ";charset=");
+                               strcat(p, charset);
+                               if (sapi_add_header(p, len, 0) != FAILURE)
+                                       SG(sapi_headers).send_default_content_type = 0;
+                       }
                        /* activate the converter */
                        MBSTRG(outconv) = mbfl_buffer_converter_new(MBSTRG(current_internal_encoding), encoding, 0);
                }