cvs: php4 /ext/mbstring mbstring.c

From: Date: Thu, 11 Apr 2002 22:27:00 +0000
Subject: cvs: php4 /ext/mbstring mbstring.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-11066@lists.php.net to get a copy of this message
hirokawa Thu Apr 11 18:27:00 2002 EDT Modified files: /php4/ext/mbstring mbstring.c Log: fixed a bug which causes crash when charset is not set. Index: php4/ext/mbstring/mbstring.c diff -u php4/ext/mbstring/mbstring.c:1.57 php4/ext/mbstring/mbstring.c:1.58 --- php4/ext/mbstring/mbstring.c:1.57 Thu Apr 11 09:40:19 2002 +++ php4/ext/mbstring/mbstring.c Thu Apr 11 18:27:00 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mbstring.c,v 1.57 2002/04/11 13:40:19 yohgaki Exp $ */ +/* $Id: mbstring.c,v 1.58 2002/04/11 22:27:00 hirokawa Exp $ */ /* * PHP4 Multibyte String module "mbstring" (currently only for Japanese) @@ -1492,14 +1492,16 @@ 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); }

« previous php.cvs (#11066) next »