From f4c96ffcb565c1daa76aa58256e4df6f111f8803 Mon Sep 17 00:00:00 2001 From: Julien Pauli Date: Fri, 20 Feb 2015 13:38:35 +0100 Subject: [PATCH 1/3] Fix #63486 --- ext/mysqli/php_mysqli_structs.h | 1 + ext/mysqli/tests/bug63486.phpt | 55 +++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 ext/mysqli/tests/bug63486.phpt diff --git a/ext/mysqli/php_mysqli_structs.h b/ext/mysqli/php_mysqli_structs.h index ce480d8fee4..52da163aa54 100644 --- a/ext/mysqli/php_mysqli_structs.h +++ b/ext/mysqli/php_mysqli_structs.h @@ -313,6 +313,7 @@ extern PHPAPI zend_class_entry *spl_ce_RuntimeException; mysqli_object *intern = (mysqli_object *)zend_object_store_get_object(*(__id) TSRMLS_CC);\ efree(intern->ptr); \ intern->ptr = NULL; \ + ZVAL_NULL(*__id); \ } diff --git a/ext/mysqli/tests/bug63486.phpt b/ext/mysqli/tests/bug63486.phpt new file mode 100644 index 00000000000..72b8663e43a --- /dev/null +++ b/ext/mysqli/tests/bug63486.phpt @@ -0,0 +1,55 @@ +--TEST-- +mysqli_free_resource() - resets the zval to NULL +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +array(1) { + [0]=> + string(1) "1" +} +object(mysqli_result)#3 (5) { + ["current_field"]=> + int(0) + ["field_count"]=> + int(1) + ["lengths"]=> + array(1) { + [0]=> + int(1) + } + ["num_rows"]=> + int(1) + ["type"]=> + int(0) +} +array(1) { + [0]=> + string(1) "1" +} +NULL From c4c3dca302df627c492e6ce885b777f21dce9f78 Mon Sep 17 00:00:00 2001 From: Julien Pauli Date: Tue, 15 Jul 2014 17:18:56 +0200 Subject: [PATCH 2/3] Fix #67626 --- ext/standard/tests/streams/bug67626.phpt | 45 ++++++++++++++++++++++++ main/streams/userspace.c | 12 ++++++- 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 ext/standard/tests/streams/bug67626.phpt diff --git a/ext/standard/tests/streams/bug67626.phpt b/ext/standard/tests/streams/bug67626.phpt new file mode 100644 index 00000000000..67c2c3f8e08 --- /dev/null +++ b/ext/standard/tests/streams/bug67626.phpt @@ -0,0 +1,45 @@ +--TEST-- +Bug #67626: Exceptions not properly handled in user stream handlers +--FILE-- +getMessage(); +} +echo "\n"; +try { + fwrite($fp, 'foobar'); +} catch (Exception $e) { + echo $e->getMessage(); +} +?> +--EXPECTF-- +stream_read_exception +stream_write_exception \ No newline at end of file diff --git a/main/streams/userspace.c b/main/streams/userspace.c index ec223534ff1..573b46f5db2 100644 --- a/main/streams/userspace.c +++ b/main/streams/userspace.c @@ -645,6 +645,11 @@ static size_t php_userstreamop_write(php_stream *stream, const char *buf, size_t zval_ptr_dtor(&zbufptr); didwrite = 0; + + if (EG(exception)) { + return 0; + } + if (call_result == SUCCESS && retval != NULL) { convert_to_long(retval); didwrite = Z_LVAL_P(retval); @@ -692,6 +697,12 @@ static size_t php_userstreamop_read(php_stream *stream, char *buf, size_t count 1, args, 0, NULL TSRMLS_CC); + zval_ptr_dtor(&zcount); + + if (EG(exception)) { + return -1; + } + if (call_result == SUCCESS && retval != NULL) { convert_to_string(retval); didread = Z_STRLEN_P(retval); @@ -706,7 +717,6 @@ static size_t php_userstreamop_read(php_stream *stream, char *buf, size_t count php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::" USERSTREAM_READ " is not implemented!", us->wrapper->classname); } - zval_ptr_dtor(&zcount); if (retval) { zval_ptr_dtor(&retval); From fa72f1ea869e23fd92c50f69a8350e50d57e1c12 Mon Sep 17 00:00:00 2001 From: Masaki Kagaya Date: Wed, 18 Feb 2015 23:17:39 +0900 Subject: [PATCH 3/3] added missing parentheses added test case for bug #68846 replaced tab with space added missing parentheses again See also: http://icu-project.org/docs/papers/gb18030.html#h7 --- NEWS | 4 ++++ ext/mbstring/libmbfl/filters/mbfilter_gb18030.c | 2 +- ext/mbstring/tests/bug68846.phpt | 12 ++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 ext/mbstring/tests/bug68846.phpt diff --git a/NEWS b/NEWS index b0af1ae8584..1c8785d7965 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,10 @@ PHP NEWS (Julian) . Fixed bug #68917 (parse_url fails on some partial urls). (Wei Dai) +- Mbstring: + . Fixed bug #68846 (False detection of CJK Unified Ideographs Extension E). + (Masaki Kagaya) + - Mysqli: . Fixed bug#63486 (mysqli_free_result leave the resource variable in a messy state). (Julian) diff --git a/ext/mbstring/libmbfl/filters/mbfilter_gb18030.c b/ext/mbstring/libmbfl/filters/mbfilter_gb18030.c index f6f12be4498..7767c6551f0 100644 --- a/ext/mbstring/libmbfl/filters/mbfilter_gb18030.c +++ b/ext/mbstring/libmbfl/filters/mbfilter_gb18030.c @@ -239,7 +239,7 @@ mbfl_filt_conv_gb18030_wchar(int c, mbfl_convert_filter *filter) if (((c1 >= 0x81 && c1 <= 0x84) || (c1 >= 0x90 && c1 <= 0xe3)) && c2 >= 0x30 && c2 <= 0x39 && c3 >= 0x81 && c3 <= 0xfe && c >= 0x30 && c <= 0x39) { if (c1 >= 0x90 && c1 <= 0xe3) { - w = ((c1 - 0x90)*10 + (c2 - 0x30)*126 + (c3 - 0x81))*10 + (c - 0x30) + 0x10000; + w = ((((c1 - 0x90)*10 + (c2 - 0x30))*126 + (c3 - 0x81)))*10 + (c - 0x30) + 0x10000; } else { /* Unicode BMP */ w = (((c1 - 0x81)*10 + (c2 - 0x30))*126 + (c3 - 0x81))*10 + (c - 0x30); if (w >= 0 && w <= 39419) { diff --git a/ext/mbstring/tests/bug68846.phpt b/ext/mbstring/tests/bug68846.phpt new file mode 100644 index 00000000000..1b43e3d11b0 --- /dev/null +++ b/ext/mbstring/tests/bug68846.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #68846 False detection of CJK Unified Ideographs Extension E +--SKIPIF-- + +--FILE-- + +--EXPECT-- +bool(true) \ No newline at end of file