summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRui Hirokawa <hirokawa@php.net>2002-04-11 22:27:00 +0000
committerRui Hirokawa <hirokawa@php.net>2002-04-11 22:27:00 +0000
commitadf58908e4d91ab76f785eed5883dac71eebe221 (patch)
tree6247b9496c74c9ddbaec28937f497d1d16c26bd3
parent22fb507325ac13a26f1b443f098f6f9764189001 (diff)
downloadphp-git-adf58908e4d91ab76f785eed5883dac71eebe221.tar.gz
fixed a bug which causes crash when charset is not set.
-rw-r--r--ext/mbstring/mbstring.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c
index 7bbc8cd233..cfd3bfdf65 100644
--- a/ext/mbstring/mbstring.c
+++ b/ext/mbstring/mbstring.c
@@ -1492,14 +1492,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 TSRMLS_CC);
}