cvs: php4(PHP_4_2_0) /ext/mbstring mbstring.c

From: Date: Fri, 12 Apr 2002 15:07:50 +0000
Subject: cvs: php4(PHP_4_2_0) /ext/mbstring mbstring.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-11083@lists.php.net to get a copy of this message
hirokawa Fri Apr 12 11:07:50 2002 EDT Modified files: (Branch: PHP_4_2_0) /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.48.2.2 php4/ext/mbstring/mbstring.c:1.48.2.3 --- php4/ext/mbstring/mbstring.c:1.48.2.2 Fri Mar 22 20:12:54 2002 +++ php4/ext/mbstring/mbstring.c Fri Apr 12 11:07:48 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mbstring.c,v 1.48.2.2 2002/03/23 01:12:54 hirokawa Exp $ */ +/* $Id: mbstring.c,v 1.48.2.3 2002/04/12 15:07:48 hirokawa Exp $ */ /* * PHP4 Multibyte String module "mbstring" (currently only for Japanese) @@ -1476,14 +1476,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); }

« previous php.cvs (#11083) next »