php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #60362
Patch fix_to_prevent_warning_on_isset_empty_for_55_and_a_half.patch revision 2011-12-21 14:34 UTC by alan_k@php.net
Patch isset_changed_warning_only_on_access.patch revision 2011-12-18 05:08 UTC by alan_k@php.net
Patch string_offset_trigger_notice.patch revision 2011-12-05 05:17 UTC by laruence@php.net
revision 2011-12-04 17:26 UTC by laruence@php.net
Patch fix_disabling_bad_string_offsets revision 2011-12-04 16:43 UTC by laruence@php.net
revision 2011-12-04 12:44 UTC by alan at akbkhome dot com
Patch first_effort_to_fix_this revision 2011-12-03 15:51 UTC by alan at akbkhome dot com
Patch bug60362.sub-sub-keys.phpt revision 2011-11-23 01:40 UTC by danielc at analysisandsolutions dot com

Patch isset_changed_warning_only_on_access.patch for Arrays related Bug #60362

Patch version 2011-12-18 05:08 UTC

Return to Bug #60362 | Download this patch
Patch Revisions:

Developer: alan_k@php.net

Index: Zend/zend_execute.c
===================================================================
--- Zend/zend_execute.c	(revision 320308)
+++ Zend/zend_execute.c	(working copy)
@@ -1138,7 +1138,6 @@
 
 		case IS_STRING: {
 				zval tmp;
-
 				if (type != BP_VAR_UNSET && Z_STRLEN_P(container)==0) {
 					goto convert_to_array;
 				}
@@ -1147,15 +1146,24 @@
 				}
 
 				if (Z_TYPE_P(dim) != IS_LONG) {
+ 
 					switch(Z_TYPE_P(dim)) {
 						/* case IS_LONG: */
 						case IS_STRING:
+							if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, -1)) {
+								break;
+							}
+							if (type != BP_VAR_UNSET) {
+								zend_error(E_WARNING, "Invalid string offset '%s'", dim->value.str.val);
+							}
+							 
+							break;
 						case IS_DOUBLE:
 						case IS_NULL:
 						case IS_BOOL:
-							/* do nothing */
+							zend_error(E_NOTICE, "String offset cast occured");
 							break;
-						default:
+						default:		 
 							zend_error(E_WARNING, "Illegal offset type");
 							break;
 					}
@@ -1265,12 +1273,19 @@
 					switch(Z_TYPE_P(dim)) {
 						/* case IS_LONG: */
 						case IS_STRING:
+							if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, -1)) {
+								break;
+							}
+							if (type != BP_VAR_IS) { 
+								zend_error(E_WARNING, "Illegal string offset '%s'", dim->value.str.val);
+							} 
+							break;
 						case IS_DOUBLE:
 						case IS_NULL:
 						case IS_BOOL:
-							/* do nothing */
+							zend_error(E_NOTICE, "String offset cast occured");
 							break;
-						default:
+						default:							 
 							zend_error(E_WARNING, "Illegal offset type");
 							break;
 					}
Index: Zend/tests/offset_string.phpt
===================================================================
--- Zend/tests/offset_string.phpt	(revision 320308)
+++ Zend/tests/offset_string.phpt	(working copy)
@@ -24,12 +24,22 @@
 
 echo "Done\n";
 ?>
---EXPECTF--	
+--EXPECTF--
 string(1) "i"
+
+Notice: String offset cast occured in %s on line %d
 string(1) "S"
+
+Notice: String offset cast occured in %s on line %d
 string(1) "S"
+
+Warning: Illegal string offset 'run away' in %s on line %d
 string(1) "S"
+
+Notice: String offset cast occured in %s on line %d
 string(1) "i"
+
+Notice: String offset cast occured in %s on line %d
 string(1) "S"
 
 Warning: Illegal offset type in %s on line %d
@@ -42,4 +52,4 @@
 
 Warning: Illegal offset type in %s on line %d
 string(1) "i"
-Done
+Done
\ No newline at end of file
Index: Zend/tests/bug39304.phpt
===================================================================
--- Zend/tests/bug39304.phpt	(revision 320308)
+++ Zend/tests/bug39304.phpt	(working copy)
@@ -7,10 +7,10 @@
 echo "I am alive";
 ?>
 --EXPECTF--
-Notice: Uninitialized string offset: 0 in %sbug39304.php on line 3
+Notice: Uninitialized string offset: 0 in %sbug39304.php on line %d
 
-Notice: Uninitialized string offset: 1 in %sbug39304.php on line 3
+Notice: Uninitialized string offset: 1 in %sbug39304.php on line %d
 
-Notice: Uninitialized string offset: 0 in %sbug39304.php on line 3
+Notice: Uninitialized string offset: 0 in %sbug39304.php on line %d
 I am alive
 
Index: Zend/tests/bug39304_2_4.phpt
===================================================================
--- Zend/tests/bug39304_2_4.phpt	(revision 320308)
+++ Zend/tests/bug39304_2_4.phpt	(working copy)
@@ -9,10 +9,10 @@
   var_dump($a,$b);
 ?>
 --EXPECTF--
-Notice: Uninitialized string offset: 0 in %sbug39304_2_4.php on line 3
+Notice: Uninitialized string offset: 0 in %sbug39304_2_4.php on line %d
 
-Notice: Uninitialized string offset: 1 in %sbug39304_2_4.php on line 3
+Notice: Uninitialized string offset: 1 in %sbug39304_2_4.php on line %d
 
-Notice: Uninitialized string offset: 0 in %sbug39304_2_4.php on line 3
+Notice: Uninitialized string offset: 0 in %sbug39304_2_4.php on line %d
 string(0) ""
 string(0) ""
Index: Zend/tests/bug39018.phpt
===================================================================
--- Zend/tests/bug39018.phpt	(revision 320308)
+++ Zend/tests/bug39018.phpt	(working copy)
@@ -63,30 +63,42 @@
 ?>
 --EXPECTF--
 
-Notice: Uninitialized string offset: %i in %s on line 6
+Notice: Uninitialized string offset: %i in %s on line %d
 
-Notice: Uninitialized string offset: 0 in %s on line 10
+Notice: Uninitialized string offset: 0 in %s on line %d
 
-Notice: Uninitialized string offset: 0 in %s on line 12
+Notice: Uninitialized string offset: 0 in %s on line %d
 
-Notice: Uninitialized string offset: %i in %s on line 14
+Notice: String offset cast occured in %s on line %d
 
-Notice: Uninitialized string offset: %i in %s on line 16
+Notice: Uninitialized string offset: %i in %s on line %d
 
-Notice: Uninitialized string offset: 0 in %s on line 18
+Notice: String offset cast occured in %s on line %d
 
-Notice: Uninitialized string offset: 4 in %s on line 28
+Notice: Uninitialized string offset: %i in %s on line %d
 
-Notice: Uninitialized string offset: 4 in %s on line 34
+Notice: Uninitialized string offset: 0 in %s on line %d
 
-Notice: Uninitialized string offset: 4 in %s on line 38
+Notice: Uninitialized string offset: 4 in %s on line %d
 
-Notice: Uninitialized string offset: 4 in %s on line 42
+Notice: Uninitialized string offset: 4 in %s on line %d
 
-Notice: Uninitialized string offset: 4 in %s on line 46
+Notice: Uninitialized string offset: 4 in %s on line %d
 
-Notice: Uninitialized string offset: 12 in %s on line 50
+Notice: Uninitialized string offset: 4 in %s on line %d
 
-Notice: Uninitialized string offset: 12 in %s on line 52
+Notice: Uninitialized string offset: 4 in %s on line %d
+
+Notice: String offset cast occured in %s on line %d
+
+Notice: Uninitialized string offset: 12 in %s on line %d
+
+Notice: String offset cast occured in %s on line %d
+
+Notice: Uninitialized string offset: 12 in %s on line %d
+
+Notice: String offset cast occured in %s on line %d
+
+Notice: String offset cast occured in %s on line %d
 b
 Done
Index: Zend/tests/result_unused.phpt
===================================================================
--- Zend/tests/result_unused.phpt	(revision 320308)
+++ Zend/tests/result_unused.phpt	(working copy)
@@ -24,6 +24,6 @@
 $x->y;
 echo "ok\n";
 --EXPECTF--
-Notice: Uninitialized string offset: 3 in %sresult_unused.php on line 11
+Notice: Uninitialized string offset: 3 in %sresult_unused.php on line %d
 ok
 
Index: Zend/tests/indexing_001.phpt
===================================================================
--- Zend/tests/indexing_001.phpt	(revision 320308)
+++ Zend/tests/indexing_001.phpt	(working copy)
@@ -71,6 +71,8 @@
   }
 }
 
+Warning: Invalid string offset 'foo' in %s on line %d
+
 Notice: Array to string conversion in %s on line %d
 string(1) "A"
 
Index: Zend/tests/bug54262.phpt
===================================================================
--- Zend/tests/bug54262.phpt	(revision 320308)
+++ Zend/tests/bug54262.phpt	(working copy)
@@ -9,7 +9,7 @@
 echo "ok\n";
 ?>
 --EXPECTF--
-bool(true)
+bool(false)
 
 Warning: Attempt to modify property of non-object in %sbug54262.php on line 4
 
Index: Zend/tests/offset_assign.phpt
===================================================================
--- Zend/tests/offset_assign.phpt	(revision 320308)
+++ Zend/tests/offset_assign.phpt	(working copy)
@@ -7,5 +7,7 @@
 
 echo "Done\n";
 ?>
---EXPECTF--	
-Fatal error: Cannot use string offset as an array in %s on line %d
+--EXPECTF--
+Warning: Invalid string offset 'x' in %soffset_assign.php on line %d
+
+Fatal error: Cannot use string offset as an array in %soffset_assign.php on line %d
Index: Zend/tests/str_offset_001.phpt
===================================================================
--- Zend/tests/str_offset_001.phpt	(revision 320308)
+++ Zend/tests/str_offset_001.phpt	(working copy)
@@ -24,28 +24,28 @@
 foo($str[2][1]);
 ?>
 --EXPECTF--
-Notice: Uninitialized string offset: -1 in %sstr_offset_001.php on line 7
+Notice: Uninitialized string offset: -1 in %sstr_offset_001.php on line %d
 string(0) ""
 string(1) "a"
 string(1) "b"
 string(1) "c"
 
-Notice: Uninitialized string offset: 3 in %sstr_offset_001.php on line 11
+Notice: Uninitialized string offset: 3 in %sstr_offset_001.php on line %d
 string(0) ""
 string(1) "b"
 
-Notice: Uninitialized string offset: 1 in %sstr_offset_001.php on line 13
+Notice: Uninitialized string offset: 1 in %sstr_offset_001.php on line %d
 string(0) ""
 
-Notice: Uninitialized string offset: -1 in %sstr_offset_001.php on line 15
+Notice: Uninitialized string offset: -1 in %sstr_offset_001.php on line %d
 string(0) ""
 string(1) "a"
 string(1) "b"
 string(1) "c"
 
-Notice: Uninitialized string offset: 3 in %sstr_offset_001.php on line 19
+Notice: Uninitialized string offset: 3 in %sstr_offset_001.php on line %d
 string(0) ""
 string(1) "b"
 
-Notice: Uninitialized string offset: 1 in %sstr_offset_001.php on line 21
+Notice: Uninitialized string offset: 1 in %sstr_offset_001.php on line %d
 string(0) ""
Index: Zend/tests/bug31098.phpt
===================================================================
--- Zend/tests/bug31098.phpt	(revision 320308)
+++ Zend/tests/bug31098.phpt	(working copy)
@@ -17,7 +17,7 @@
 
 $simpleString = "Bogus String Text";
 echo isset($simpleString->wrong)?"bug\n":"ok\n";
-echo isset($simpleString["wrong"])?"ok\n":"bug\n";
+echo isset($simpleString["wrong"])?"bug\n":"ok\n";
 echo isset($simpleString[-1])?"bug\n":"ok\n";
 echo isset($simpleString[0])?"ok\n":"bug\n";
 echo isset($simpleString["0"])?"ok\n":"bug\n";
@@ -34,8 +34,8 @@
 bool(false)
 bool(false)
 bool(false)
-bool(true)
-bool(true)
+bool(false)
+bool(false)
 ok
 ok
 ok
@@ -44,8 +44,12 @@
 ok
 ok
 
-Notice: Trying to get property of non-object in %sbug31098.php on line %d
+Notice: Trying to get property of non-object in %s on line %d
 ok
+
+Warning: Illegal string offset 'wrong' in %s on line %d
 ok
 ok
-ok
+
+Warning: Invalid string offset 'wrong' in %s on line %d
+ok
\ No newline at end of file
Index: Zend/zend_vm_def.h
===================================================================
--- Zend/zend_vm_def.h	(revision 320308)
+++ Zend/zend_vm_def.h	(working copy)
@@ -4507,10 +4507,18 @@
 		zval tmp;
 
 		if (Z_TYPE_P(offset) != IS_LONG) {
-			ZVAL_COPY_VALUE(&tmp, offset);
-			zval_copy_ctor(&tmp);
-			convert_to_long(&tmp);
-			offset = &tmp;
+			/** if it's an object/array etc.. */
+			if (((Z_TYPE_P(offset) != IS_STRING) &&(Z_TYPE_P(offset) != IS_DOUBLE)
+					   	&& (Z_TYPE_P(offset) != IS_NULL) && (Z_TYPE_P(offset) != IS_BOOL))
+					|| ((Z_TYPE_P(offset) == IS_STRING) 
+						&& (IS_LONG != is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, -1)))) {
+				result = 0;
+			} else {
+				ZVAL_COPY_VALUE(&tmp, offset);
+				zval_copy_ctor(&tmp);
+				convert_to_long(&tmp);
+				offset = &tmp;
+			}
 		}
 		if (Z_TYPE_P(offset) == IS_LONG) {
 			if (opline->extended_value & ZEND_ISSET) {
Index: Zend/zend_vm_execute.h
===================================================================
--- Zend/zend_vm_execute.h	(revision 320308)
+++ Zend/zend_vm_execute.h	(working copy)
@@ -14035,10 +14035,18 @@
 		zval tmp;
 
 		if (Z_TYPE_P(offset) != IS_LONG) {
-			ZVAL_COPY_VALUE(&tmp, offset);
-			zval_copy_ctor(&tmp);
-			convert_to_long(&tmp);
-			offset = &tmp;
+			/** if it's an object/array etc.. */
+			if (((Z_TYPE_P(offset) != IS_STRING) &&(Z_TYPE_P(offset) != IS_DOUBLE)
+					   	&& (Z_TYPE_P(offset) != IS_NULL) && (Z_TYPE_P(offset) != IS_BOOL))
+					|| ((Z_TYPE_P(offset) == IS_STRING)
+						&& (IS_LONG != is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, -1)))) {
+				result = 0;
+			} else {
+				ZVAL_COPY_VALUE(&tmp, offset);
+				zval_copy_ctor(&tmp);
+				convert_to_long(&tmp);
+				offset = &tmp;
+			}
 		}
 		if (Z_TYPE_P(offset) == IS_LONG) {
 			if (opline->extended_value & ZEND_ISSET) {
@@ -15941,10 +15949,18 @@
 		zval tmp;
 
 		if (Z_TYPE_P(offset) != IS_LONG) {
-			ZVAL_COPY_VALUE(&tmp, offset);
-			zval_copy_ctor(&tmp);
-			convert_to_long(&tmp);
-			offset = &tmp;
+			/** if it's an object/array etc.. */
+			if (((Z_TYPE_P(offset) != IS_STRING) &&(Z_TYPE_P(offset) != IS_DOUBLE)
+					   	&& (Z_TYPE_P(offset) != IS_NULL) && (Z_TYPE_P(offset) != IS_BOOL))
+					|| ((Z_TYPE_P(offset) == IS_STRING)
+						&& (IS_LONG != is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, -1)))) {
+				result = 0;
+			} else {
+				ZVAL_COPY_VALUE(&tmp, offset);
+				zval_copy_ctor(&tmp);
+				convert_to_long(&tmp);
+				offset = &tmp;
+			}
 		}
 		if (Z_TYPE_P(offset) == IS_LONG) {
 			if (opline->extended_value & ZEND_ISSET) {
@@ -18205,10 +18221,18 @@
 		zval tmp;
 
 		if (Z_TYPE_P(offset) != IS_LONG) {
-			ZVAL_COPY_VALUE(&tmp, offset);
-			zval_copy_ctor(&tmp);
-			convert_to_long(&tmp);
-			offset = &tmp;
+			/** if it's an object/array etc.. */
+			if (((Z_TYPE_P(offset) != IS_STRING) &&(Z_TYPE_P(offset) != IS_DOUBLE)
+					   	&& (Z_TYPE_P(offset) != IS_NULL) && (Z_TYPE_P(offset) != IS_BOOL))
+					|| ((Z_TYPE_P(offset) == IS_STRING)
+						&& (IS_LONG != is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, -1)))) {
+				result = 0;
+			} else {
+				ZVAL_COPY_VALUE(&tmp, offset);
+				zval_copy_ctor(&tmp);
+				convert_to_long(&tmp);
+				offset = &tmp;
+			}
 		}
 		if (Z_TYPE_P(offset) == IS_LONG) {
 			if (opline->extended_value & ZEND_ISSET) {
@@ -21119,10 +21143,18 @@
 		zval tmp;
 
 		if (Z_TYPE_P(offset) != IS_LONG) {
-			ZVAL_COPY_VALUE(&tmp, offset);
-			zval_copy_ctor(&tmp);
-			convert_to_long(&tmp);
-			offset = &tmp;
+			/** if it's an object/array etc.. */
+			if (((Z_TYPE_P(offset) != IS_STRING) &&(Z_TYPE_P(offset) != IS_DOUBLE)
+					   	&& (Z_TYPE_P(offset) != IS_NULL) && (Z_TYPE_P(offset) != IS_BOOL))
+					|| ((Z_TYPE_P(offset) == IS_STRING)
+						&& (IS_LONG != is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, -1)))) {
+				result = 0;
+			} else {
+				ZVAL_COPY_VALUE(&tmp, offset);
+				zval_copy_ctor(&tmp);
+				convert_to_long(&tmp);
+				offset = &tmp;
+			}
 		}
 		if (Z_TYPE_P(offset) == IS_LONG) {
 			if (opline->extended_value & ZEND_ISSET) {
@@ -22446,10 +22478,18 @@
 		zval tmp;
 
 		if (Z_TYPE_P(offset) != IS_LONG) {
-			ZVAL_COPY_VALUE(&tmp, offset);
-			zval_copy_ctor(&tmp);
-			convert_to_long(&tmp);
-			offset = &tmp;
+			/** if it's an object/array etc.. */
+			if (((Z_TYPE_P(offset) != IS_STRING) &&(Z_TYPE_P(offset) != IS_DOUBLE)
+					   	&& (Z_TYPE_P(offset) != IS_NULL) && (Z_TYPE_P(offset) != IS_BOOL))
+					|| ((Z_TYPE_P(offset) == IS_STRING)
+						&& (IS_LONG != is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, -1)))) {
+				result = 0;
+			} else {
+				ZVAL_COPY_VALUE(&tmp, offset);
+				zval_copy_ctor(&tmp);
+				convert_to_long(&tmp);
+				offset = &tmp;
+			}
 		}
 		if (Z_TYPE_P(offset) == IS_LONG) {
 			if (opline->extended_value & ZEND_ISSET) {
@@ -23596,10 +23636,18 @@
 		zval tmp;
 
 		if (Z_TYPE_P(offset) != IS_LONG) {
-			ZVAL_COPY_VALUE(&tmp, offset);
-			zval_copy_ctor(&tmp);
-			convert_to_long(&tmp);
-			offset = &tmp;
+			/** if it's an object/array etc.. */
+			if (((Z_TYPE_P(offset) != IS_STRING) &&(Z_TYPE_P(offset) != IS_DOUBLE)
+					   	&& (Z_TYPE_P(offset) != IS_NULL) && (Z_TYPE_P(offset) != IS_BOOL))
+					|| ((Z_TYPE_P(offset) == IS_STRING)
+						&& (IS_LONG != is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, -1)))) {
+				result = 0;
+			} else {
+				ZVAL_COPY_VALUE(&tmp, offset);
+				zval_copy_ctor(&tmp);
+				convert_to_long(&tmp);
+				offset = &tmp;
+			}
 		}
 		if (Z_TYPE_P(offset) == IS_LONG) {
 			if (opline->extended_value & ZEND_ISSET) {
@@ -24746,10 +24794,18 @@
 		zval tmp;
 
 		if (Z_TYPE_P(offset) != IS_LONG) {
-			ZVAL_COPY_VALUE(&tmp, offset);
-			zval_copy_ctor(&tmp);
-			convert_to_long(&tmp);
-			offset = &tmp;
+			/** if it's an object/array etc.. */
+			if (((Z_TYPE_P(offset) != IS_STRING) &&(Z_TYPE_P(offset) != IS_DOUBLE)
+					   	&& (Z_TYPE_P(offset) != IS_NULL) && (Z_TYPE_P(offset) != IS_BOOL))
+					|| ((Z_TYPE_P(offset) == IS_STRING)
+						&& (IS_LONG != is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, -1)))) {
+				result = 0;
+			} else {
+				ZVAL_COPY_VALUE(&tmp, offset);
+				zval_copy_ctor(&tmp);
+				convert_to_long(&tmp);
+				offset = &tmp;
+			}
 		}
 		if (Z_TYPE_P(offset) == IS_LONG) {
 			if (opline->extended_value & ZEND_ISSET) {
@@ -26162,10 +26218,18 @@
 		zval tmp;
 
 		if (Z_TYPE_P(offset) != IS_LONG) {
-			ZVAL_COPY_VALUE(&tmp, offset);
-			zval_copy_ctor(&tmp);
-			convert_to_long(&tmp);
-			offset = &tmp;
+			/** if it's an object/array etc.. */
+			if (((Z_TYPE_P(offset) != IS_STRING) &&(Z_TYPE_P(offset) != IS_DOUBLE)
+					   	&& (Z_TYPE_P(offset) != IS_NULL) && (Z_TYPE_P(offset) != IS_BOOL))
+					|| ((Z_TYPE_P(offset) == IS_STRING)
+						&& (IS_LONG != is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, -1)))) {
+				result = 0;
+			} else {
+				ZVAL_COPY_VALUE(&tmp, offset);
+				zval_copy_ctor(&tmp);
+				convert_to_long(&tmp);
+				offset = &tmp;
+			}
 		}
 		if (Z_TYPE_P(offset) == IS_LONG) {
 			if (opline->extended_value & ZEND_ISSET) {
@@ -29470,10 +29534,18 @@
 		zval tmp;
 
 		if (Z_TYPE_P(offset) != IS_LONG) {
-			ZVAL_COPY_VALUE(&tmp, offset);
-			zval_copy_ctor(&tmp);
-			convert_to_long(&tmp);
-			offset = &tmp;
+			/** if it's an object/array etc.. */
+			if (((Z_TYPE_P(offset) != IS_STRING) &&(Z_TYPE_P(offset) != IS_DOUBLE)
+					   	&& (Z_TYPE_P(offset) != IS_NULL) && (Z_TYPE_P(offset) != IS_BOOL))
+					|| ((Z_TYPE_P(offset) == IS_STRING)
+						&& (IS_LONG != is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, -1)))) {
+				result = 0;
+			} else {
+				ZVAL_COPY_VALUE(&tmp, offset);
+				zval_copy_ctor(&tmp);
+				convert_to_long(&tmp);
+				offset = &tmp;
+			}
 		}
 		if (Z_TYPE_P(offset) == IS_LONG) {
 			if (opline->extended_value & ZEND_ISSET) {
@@ -31250,10 +31322,18 @@
 		zval tmp;
 
 		if (Z_TYPE_P(offset) != IS_LONG) {
-			ZVAL_COPY_VALUE(&tmp, offset);
-			zval_copy_ctor(&tmp);
-			convert_to_long(&tmp);
-			offset = &tmp;
+			/** if it's an object/array etc.. */
+			if (((Z_TYPE_P(offset) != IS_STRING) &&(Z_TYPE_P(offset) != IS_DOUBLE)
+					   	&& (Z_TYPE_P(offset) != IS_NULL) && (Z_TYPE_P(offset) != IS_BOOL))
+					|| ((Z_TYPE_P(offset) == IS_STRING)
+						&& (IS_LONG != is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, -1)))) {
+				result = 0;
+			} else {
+				ZVAL_COPY_VALUE(&tmp, offset);
+				zval_copy_ctor(&tmp);
+				convert_to_long(&tmp);
+				offset = &tmp;
+			}
 		}
 		if (Z_TYPE_P(offset) == IS_LONG) {
 			if (opline->extended_value & ZEND_ISSET) {
@@ -33387,10 +33467,18 @@
 		zval tmp;
 
 		if (Z_TYPE_P(offset) != IS_LONG) {
-			ZVAL_COPY_VALUE(&tmp, offset);
-			zval_copy_ctor(&tmp);
-			convert_to_long(&tmp);
-			offset = &tmp;
+			/** if it's an object/array etc.. */
+			if (((Z_TYPE_P(offset) != IS_STRING) &&(Z_TYPE_P(offset) != IS_DOUBLE)
+					   	&& (Z_TYPE_P(offset) != IS_NULL) && (Z_TYPE_P(offset) != IS_BOOL))
+					|| ((Z_TYPE_P(offset) == IS_STRING)
+						&& (IS_LONG != is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, -1)))) {
+				result = 0;
+			} else {
+				ZVAL_COPY_VALUE(&tmp, offset);
+				zval_copy_ctor(&tmp);
+				convert_to_long(&tmp);
+				offset = &tmp;
+			}
 		}
 		if (Z_TYPE_P(offset) == IS_LONG) {
 			if (opline->extended_value & ZEND_ISSET) {
@@ -36038,10 +36126,18 @@
 		zval tmp;
 
 		if (Z_TYPE_P(offset) != IS_LONG) {
-			ZVAL_COPY_VALUE(&tmp, offset);
-			zval_copy_ctor(&tmp);
-			convert_to_long(&tmp);
-			offset = &tmp;
+			/** if it's an object/array etc.. */
+			if (((Z_TYPE_P(offset) != IS_STRING) &&(Z_TYPE_P(offset) != IS_DOUBLE)
+					   	&& (Z_TYPE_P(offset) != IS_NULL) && (Z_TYPE_P(offset) != IS_BOOL))
+					|| ((Z_TYPE_P(offset) == IS_STRING)
+						&& (IS_LONG != is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, -1)))) {
+				result = 0;
+			} else {
+				ZVAL_COPY_VALUE(&tmp, offset);
+				zval_copy_ctor(&tmp);
+				convert_to_long(&tmp);
+				offset = &tmp;
+			}
 		}
 		if (Z_TYPE_P(offset) == IS_LONG) {
 			if (opline->extended_value & ZEND_ISSET) {
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 02:01:28 2024 UTC