Hi Moriyoshi,

I just came from long vacation and found most of the ext/mbstring related tests failed. Looking into the problems I found a lot of places where PHP crashes because of NULL pointer deference. Some other tests produce incorrect output.


Have you tried to run "make test" with your patch?

Could you please fix the bugs you introduced or revert the patch.

I've attached a patch that fixes some of mbstring crashes.

Thanks. Dmitry.

On 12/19/2010 07:36 PM, Moriyoshi Koizumi wrote:
moriyoshi                                Sun, 19 Dec 2010 16:36:37 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=306453

Log:
* Refactor zend_multibyte facility.
   Now mbstring.script_encoding is superseded by zend.script_encoding.

Changed paths:
<changed paths exceeded maximum size>


Index: ext/mbstring/mbstring.c
===================================================================
--- ext/mbstring/mbstring.c	(revision 307402)
+++ ext/mbstring/mbstring.c	(working copy)
@@ -2025,7 +2025,7 @@
 		return;
 	}
 
-	encoding = MBSTRG(current_http_output_encoding);
+	encoding = MBSTRG(current_http_output_encoding) ? MBSTRG(current_http_output_encoding) : &mbfl_encoding_pass;
 
  	/* start phase only */
  	if ((arg_status & PHP_OUTPUT_HANDLER_START) != 0) {
@@ -2086,7 +2086,7 @@
  	/* feed the string */
  	mbfl_string_init(&string);
  	string.no_language = MBSTRG(language);
- 	string.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;
+ 	string.no_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->no_encoding : mbfl_no_encoding_pass;
  	string.val = (unsigned char *)arg_string;
  	string.len = arg_string_len;
  	mbfl_buffer_converter_feed(MBSTRG(outconv), &string);
@@ -2123,7 +2123,7 @@
 
 	string.no_language = MBSTRG(language);
 	if (enc_name == NULL) {
-		string.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;
+		string.no_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->no_encoding : mbfl_no_encoding_pass;
 	} else {
 		string.no_encoding = mbfl_name2no_encoding(enc_name);
 		if (string.no_encoding == mbfl_no_encoding_invalid) {
@@ -2154,9 +2154,9 @@
 	mbfl_string_init(&haystack);
 	mbfl_string_init(&needle);
 	haystack.no_language = MBSTRG(language);
-	haystack.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;
+	haystack.no_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->no_encoding : mbfl_no_encoding_pass;
 	needle.no_language = MBSTRG(language);
-	needle.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;
+	needle.no_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->no_encoding : mbfl_no_encoding_pass;
 	offset = 0;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|ls", (char **)&haystack.val, &haystack.len, (char **)&needle.val, &needle.len, &offset, &enc_name, &enc_name_len) == FAILURE) {
@@ -2221,9 +2221,9 @@
 	mbfl_string_init(&haystack);
 	mbfl_string_init(&needle);
 	haystack.no_language = MBSTRG(language);
-	haystack.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;
+	haystack.no_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->no_encoding : mbfl_no_encoding_pass;
 	needle.no_language = MBSTRG(language);
-	needle.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;
+	needle.no_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->no_encoding : mbfl_no_encoding_pass;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|Zs", (char **)&haystack.val, &haystack.len, (char **)&needle.val, &needle.len, &zoffset, &enc_name, &enc_name_len) == FAILURE) {
 		RETURN_FALSE;
@@ -2310,7 +2310,7 @@
 	int n;
 	long offset;
 	mbfl_string haystack, needle;
-	const char *from_encoding = MBSTRG(current_internal_encoding)->mime_name;
+	const char *from_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->mime_name : NULL;
 	int from_encoding_len;
 	n = -1;
 	offset = 0;
@@ -2339,7 +2339,7 @@
 	int n;
 	long offset;
 	mbfl_string haystack, needle;
-	const char *from_encoding = MBSTRG(current_internal_encoding)->mime_name;
+	const char *from_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->mime_name : NULL;
 	int from_encoding_len;
 	n = -1;
 	offset = 0;
@@ -2371,9 +2371,9 @@
 	mbfl_string_init(&haystack);
 	mbfl_string_init(&needle);
 	haystack.no_language = MBSTRG(language);
-	haystack.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;
+	haystack.no_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->no_encoding : mbfl_no_encoding_pass;
 	needle.no_language = MBSTRG(language);
-	needle.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;
+	needle.no_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->no_encoding : mbfl_no_encoding_pass;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|bs", (char **)&haystack.val, (int *)&haystack.len, (char **)&needle.val, (int *)&needle.len, &part, &enc_name, &enc_name_len) == FAILURE) {
 		RETURN_FALSE;
@@ -2429,9 +2429,9 @@
 	mbfl_string_init(&haystack);
 	mbfl_string_init(&needle);
 	haystack.no_language = MBSTRG(language);
-	haystack.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;
+	haystack.no_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->no_encoding : mbfl_no_encoding_pass;
 	needle.no_language = MBSTRG(language);
-	needle.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;
+	needle.no_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->no_encoding : mbfl_no_encoding_pass;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|bs", (char **)&haystack.val, &haystack.len, (char **)&needle.val, &needle.len, &part, &enc_name, &enc_name_len) == FAILURE) {
 		RETURN_FALSE;
@@ -2484,13 +2484,13 @@
 	unsigned int from_encoding_len, len, mblen;
 	int n;
 	mbfl_string haystack, needle, result, *ret = NULL;
-	const char *from_encoding = MBSTRG(current_internal_encoding)->mime_name;
+	const char *from_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->mime_name : NULL;
 	mbfl_string_init(&haystack);
 	mbfl_string_init(&needle);
 	haystack.no_language = MBSTRG(language);
-	haystack.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;
+	haystack.no_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->no_encoding : mbfl_no_encoding_pass;
 	needle.no_language = MBSTRG(language);
-	needle.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;
+	needle.no_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->no_encoding : mbfl_no_encoding_pass;
 
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|bs", (char **)&haystack.val, &haystack.len, (char **)&needle.val, &needle.len, &part, &from_encoding, &from_encoding_len) == FAILURE) {
@@ -2542,13 +2542,13 @@
 	zend_bool part = 0;
 	int n, from_encoding_len, len, mblen;
 	mbfl_string haystack, needle, result, *ret = NULL;
-	const char *from_encoding = MBSTRG(current_internal_encoding)->name;
+	const char *from_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->name : NULL;
 	mbfl_string_init(&haystack);
 	mbfl_string_init(&needle);
 	haystack.no_language = MBSTRG(language);
-	haystack.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;
+	haystack.no_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->no_encoding : mbfl_no_encoding_pass;
 	needle.no_language = MBSTRG(language);
-	needle.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;
+	needle.no_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->no_encoding : mbfl_no_encoding_pass;
 
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|bs", (char **)&haystack.val, &haystack.len, (char **)&needle.val, &needle.len, &part, &from_encoding, &from_encoding_len) == FAILURE) {
@@ -2600,9 +2600,9 @@
 	mbfl_string_init(&haystack);
 	mbfl_string_init(&needle);
 	haystack.no_language = MBSTRG(language);
-	haystack.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;
+	haystack.no_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->no_encoding : mbfl_no_encoding_pass;
 	needle.no_language = MBSTRG(language);
-	needle.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;
+	needle.no_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->no_encoding : mbfl_no_encoding_pass;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|s", (char **)&haystack.val, &haystack.len, (char **)&needle.val, &needle.len, &enc_name, &enc_name_len) == FAILURE) {
 		return;
@@ -2646,7 +2646,7 @@
 
 	mbfl_string_init(&string);
 	string.no_language = MBSTRG(language);
-	string.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;
+	string.no_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->no_encoding : mbfl_no_encoding_pass;
 
 	if (argc == 4) {
 		string.no_encoding = mbfl_name2no_encoding(encoding);
@@ -2715,7 +2715,7 @@
 
 	mbfl_string_init(&string);
 	string.no_language = MBSTRG(language);
-	string.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;
+	string.no_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->no_encoding : mbfl_no_encoding_pass;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl|ls", (char **)&string.val, (int **)&string.len, &from, &len, &encoding, &encoding_len) == FAILURE) {
 		return;
@@ -2778,7 +2778,7 @@
 	mbfl_string_init(&string);
 
 	string.no_language = MBSTRG(language);
-	string.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;
+	string.no_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->no_encoding : mbfl_no_encoding_pass;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", (char **)&string.val, &string.len, &enc_name, &enc_name_len) == FAILURE) {
 		return;
@@ -2817,9 +2817,9 @@
 	mbfl_string_init(&string);
 	mbfl_string_init(&marker);
 	string.no_language = MBSTRG(language);
-	string.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;
+	string.no_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->no_encoding : mbfl_no_encoding_pass;
 	marker.no_language = MBSTRG(language);
-	marker.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;
+	marker.no_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->no_encoding : mbfl_no_encoding_pass;
 	marker.val = NULL;
 	marker.len = 0;
 
@@ -2889,7 +2889,7 @@
 	/* initialize string */
 	mbfl_string_init(&string);
 	mbfl_string_init(&result);
-	from_encoding = MBSTRG(current_internal_encoding);
+	from_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding) : &mbfl_encoding_pass;
 	string.no_encoding = from_encoding->no_encoding;
 	string.no_language = MBSTRG(language);
 	string.val = (unsigned char *)input;
@@ -2910,7 +2910,7 @@
 				string.no_encoding = from_encoding->no_encoding;
 			} else {
 				php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to detect character encoding");
-				from_encoding = mbfl_no_encoding_pass;
+				from_encoding = &mbfl_encoding_pass;
 				to_encoding = from_encoding;
 				string.no_encoding = from_encoding->no_encoding;
 			}
@@ -3024,7 +3024,7 @@
    Returns a case-folded version of sourcestring */
 PHP_FUNCTION(mb_convert_case)
 {
-	const char *from_encoding = MBSTRG(current_internal_encoding)->mime_name;
+	const char *from_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->mime_name : "pass";
 	char *str;
 	int str_len, from_encoding_len;
 	long case_mode = 0;
@@ -3049,7 +3049,7 @@
  */
 PHP_FUNCTION(mb_strtoupper)
 {
-	const char *from_encoding = MBSTRG(current_internal_encoding)->mime_name;
+	const char *from_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->mime_name : "pass";
 	char *str;
 	int str_len, from_encoding_len;
 	char *newstr;
@@ -3073,7 +3073,7 @@
  */
 PHP_FUNCTION(mb_strtolower)
 {
-	const char *from_encoding = MBSTRG(current_internal_encoding)->mime_name;
+	const char *from_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->mime_name : "pass";
 	char *str;
 	int str_len, from_encoding_len;
 	char *newstr;
@@ -3230,7 +3230,7 @@
 
 	mbfl_string_init(&string);
 	string.no_language = MBSTRG(language);
-	string.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;
+	string.no_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->no_encoding : mbfl_no_encoding_pass;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|sssl", (char **)&string.val, &string.len, &charset_name, &charset_name_len, &trans_enc_name, &trans_enc_name_len, &linefeed, &linefeed_len, &indent) == FAILURE) {
 		return;
@@ -3279,14 +3279,14 @@
 
 	mbfl_string_init(&string);
 	string.no_language = MBSTRG(language);
-	string.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;
+	string.no_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->no_encoding : mbfl_no_encoding_pass;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", (char **)&string.val, &string.len) == FAILURE) {
 		return;
 	}
 
 	mbfl_string_init(&result);
-	ret = mbfl_mime_header_decode(&string, &result, MBSTRG(current_internal_encoding)->no_encoding);
+	ret = mbfl_mime_header_decode(&string, &result, MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->no_encoding : mbfl_no_encoding_pass);
 	if (ret != NULL) {
 		RETVAL_STRINGL((char *)ret->val, ret->len, 0);	/* the string is already strdup()'ed */
 	} else {
@@ -3308,7 +3308,7 @@
 
 	mbfl_string_init(&string);
 	string.no_language = MBSTRG(language);
-	string.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;
+	string.no_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->no_encoding : mbfl_no_encoding_pass;
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ss", (char **)&string.val, &string.len, &optstr, &optstr_len, &encname, &encname_len) == FAILURE) {
 		return;
@@ -3432,7 +3432,7 @@
 	mbfl_string_init(&string);
 	mbfl_string_init(&result);
 	from_encoding = MBSTRG(current_internal_encoding);
-	string.no_encoding = from_encoding->no_encoding;
+	string.no_encoding = from_encoding ? from_encoding->no_encoding : mbfl_no_encoding_pass;
 	string.no_language = MBSTRG(language);
 
 	/* pre-conversion encoding */
@@ -3448,7 +3448,7 @@
 		break;
 	}
 	if (elistsz <= 0) {
-		from_encoding = mbfl_no_encoding_pass;
+		from_encoding = &mbfl_encoding_pass;
 	} else if (elistsz == 1) {
 		from_encoding = *elist;
 	} else {
@@ -3517,7 +3517,7 @@
 
 		if (!from_encoding) {
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to detect encoding");
-			from_encoding = mbfl_no_encoding_pass;
+			from_encoding = &mbfl_encoding_pass;
 		}
 	}
 	if (elist != NULL) {
@@ -3525,7 +3525,7 @@
 	}
 	/* create converter */
 	convd = NULL;
-	if (from_encoding != mbfl_no_encoding_pass) {
+	if (from_encoding && from_encoding != &mbfl_encoding_pass) {
 		convd = mbfl_buffer_converter_new2(from_encoding, to_encoding, 0);
 		if (convd == NULL) {
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to create converter");
@@ -3636,7 +3636,7 @@
 
 	mbfl_string_init(&string);
 	string.no_language = MBSTRG(language);
-	string.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;
+	string.no_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->no_encoding : mbfl_no_encoding_pass;
 	string.val = (unsigned char *)str;
 	string.len = str_len;
 
@@ -4089,7 +4089,7 @@
 		orig_str.no_language = MBSTRG(language);
 		orig_str.val = (unsigned char *)subject;
 		orig_str.len = subject_len;
-		orig_str.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;
+		orig_str.no_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->no_encoding : mbfl_no_encoding_pass;
 		if (orig_str.no_encoding == mbfl_no_encoding_invalid || orig_str.no_encoding == mbfl_no_encoding_pass) {
 			const mbfl_encoding *encoding = mbfl_identify_encoding2(&orig_str, MBSTRG(current_detect_order_list), MBSTRG(current_detect_order_list_size), MBSTRG(strict_detection));
 			orig_str.no_encoding = encoding ? encoding->no_encoding: mbfl_no_encoding_invalid;
@@ -4108,7 +4108,7 @@
 		orig_str.no_language = MBSTRG(language);
 		orig_str.val = (unsigned char *)message;
 		orig_str.len = (unsigned int)message_len;
-		orig_str.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;
+		orig_str.no_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->no_encoding : mbfl_no_encoding_pass;
 
 		if (orig_str.no_encoding == mbfl_no_encoding_invalid || orig_str.no_encoding == mbfl_no_encoding_pass) {
 			const mbfl_encoding *encoding = mbfl_identify_encoding2(&orig_str, MBSTRG(current_detect_order_list), MBSTRG(current_detect_order_list_size), MBSTRG(strict_detection));
@@ -4235,13 +4235,13 @@
 	if (!typ || !strcasecmp("all", typ)) {
 		array_init(return_value);
 		if (MBSTRG(current_internal_encoding)) {
-			add_assoc_string(return_value, "internal_encoding", (char *)MBSTRG(current_internal_encoding)->name, 1);
+			add_assoc_string(return_value, "internal_encoding", (char *)(MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->name : "pass"), 1);
 		}
 		if (MBSTRG(http_input_identify)) {
-			add_assoc_string(return_value, "http_input", (char *)MBSTRG(http_input_identify)->name, 1);
+			add_assoc_string(return_value, "http_input", (char *)(MBSTRG(http_input_identify) ? MBSTRG(http_input_identify)->name : "pass"), 1);
 		}
 		if (MBSTRG(current_http_output_encoding)) {
-			add_assoc_string(return_value, "http_output", (char *)MBSTRG(current_http_output_encoding)->name, 1);
+			add_assoc_string(return_value, "http_output", (char *)(MBSTRG(current_http_output_encoding) ? MBSTRG(current_http_output_encoding)->name : "pass"), 1);
 		}
 		if ((name = (char *)zend_ini_string("mbstring.http_output_conv_mimetypes", sizeof("mbstring.http_output_conv_mimetypes"), 0)) != NULL) {
 			add_assoc_string(return_value, "http_output_conv_mimetypes", name, 1);
@@ -4309,15 +4309,15 @@
 		}
 	} else if (!strcasecmp("internal_encoding", typ)) {
 		if (MBSTRG(current_internal_encoding)) {
-			RETVAL_STRING((char *)MBSTRG(current_internal_encoding)->name, 1);
+			RETVAL_STRING((char *)(MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->name : "pass"), 1);
 		}		
 	} else if (!strcasecmp("http_input", typ)) {
 		if (MBSTRG(http_input_identify)) {
-			RETVAL_STRING((char *)MBSTRG(http_input_identify)->name, 1);
+			RETVAL_STRING((char *)(MBSTRG(http_input_identify) ? MBSTRG(http_input_identify)->name : "pass"), 1);
 		}		
 	} else if (!strcasecmp("http_output", typ)) {
 		if (MBSTRG(current_http_output_encoding)) {
-			RETVAL_STRING((char *)MBSTRG(current_http_output_encoding)->name, 1);
+			RETVAL_STRING((char *)(MBSTRG(current_http_output_encoding) ? MBSTRG(current_http_output_encoding)->name : "pass"), 1);
 		}		
 	} else if (!strcasecmp("http_output_conv_mimetypes", typ)) {
 		if ((name = (char *)zend_ini_string("mbstring.http_output_conv_mimetypes", sizeof("mbstring.http_output_conv_mimetypes"), 0)) != NULL) {
@@ -4605,7 +4605,7 @@
 		from_encoding = MBSTRG(http_input_identify);
 	}
 
-	if (from_encoding == mbfl_no_encoding_pass) {
+	if (!from_encoding && from_encoding == &mbfl_encoding_pass) {
 		return 0;
 	}
 
@@ -4718,9 +4718,9 @@
 	mbfl_string_init(&haystack);
 	mbfl_string_init(&needle);
 	haystack.no_language = MBSTRG(language);
-	haystack.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;
+	haystack.no_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->no_encoding : mbfl_no_encoding_pass;
 	needle.no_language = MBSTRG(language);
-	needle.no_encoding = MBSTRG(current_internal_encoding)->no_encoding;
+	needle.no_encoding = MBSTRG(current_internal_encoding) ? MBSTRG(current_internal_encoding)->no_encoding : mbfl_no_encoding_pass;
 
 	do {
 		size_t len = 0;
Index: ext/mbstring/mb_gpc.c
===================================================================
--- ext/mbstring/mb_gpc.c	(revision 307402)
+++ ext/mbstring/mb_gpc.c	(working copy)
@@ -205,9 +205,9 @@
 	mbfl_encoding_detector *identd = NULL; 
 	mbfl_buffer_converter *convd = NULL;
 
-	mbfl_string_init_set(&string, info->to_language, info->to_encoding->no_encoding);
-	mbfl_string_init_set(&resvar, info->to_language, info->to_encoding->no_encoding);
-	mbfl_string_init_set(&resval, info->to_language, info->to_encoding->no_encoding);
+	mbfl_string_init_set(&string, info->to_language, info->to_encoding ? info->to_encoding->no_encoding : mbfl_no_encoding_pass);
+	mbfl_string_init_set(&resvar, info->to_language, info->to_encoding ? info->to_encoding->no_encoding : mbfl_no_encoding_pass);
+	mbfl_string_init_set(&resval, info->to_language, info->to_encoding ? info->to_encoding->no_encoding : mbfl_no_encoding_pass);
 
 	if (!res || *res == '\0') {
 		goto out;
@@ -282,7 +282,7 @@
 			if (info->report_errors) {
 				php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to detect encoding");
 			}
-			from_encoding = mbfl_no_encoding_pass;
+			from_encoding = &mbfl_encoding_pass;
 		}
 	}
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to