php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #55325
Patch bug55325.patch revision 2011-07-30 15:34 UTC by laruence@php.net

Patch bug55325.patch for Scripting Engine problem Bug #55325

Patch version 2011-07-30 15:34 UTC

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

Developer: laruence@php.net

Index: Zend/zend_hash.c
===================================================================
--- Zend/zend_hash.c	(revision 313966)
+++ Zend/zend_hash.c	(working copy)
@@ -1187,14 +1187,25 @@
 			}
 
 			if (mode != HASH_UPDATE_KEY_ANYWAY) {
-				Bucket *q = ht->arBuckets[num_index & ht->nTableMask];
-				int found = 0;
+				Bucket *q, *t;
+				int before = 0;
 
+				q = ht->arBuckets[num_index & ht->nTableMask];
+				t = ht->pListHead;
+				while (t) {
+					if (t == q) {
+						before = 1;
+						break;
+					}
+					if (t == p) {
+						break;
+					}
+					t = t->pListNext;
+				}
+
 				while (q != NULL) {
-					if (q == p) {
-						found = 1;
-					} else if (!q->nKeyLength && q->h == num_index) {
-						if (found) {
+					if (!q->nKeyLength && q->h == num_index) {
+						if (before) {
 							if (mode & HASH_UPDATE_KEY_IF_BEFORE) {
 								break;
 							} else {
@@ -1230,16 +1241,27 @@
 			}
 
 			if (mode != HASH_UPDATE_KEY_ANYWAY) {
+				Bucket *q, *t;
+				int before = 0;
 				ulong h = zend_inline_hash_func(str_index, str_length);
-				Bucket *q = ht->arBuckets[h & ht->nTableMask];
-				int found = 0;
 
+				q = ht->arBuckets[h & ht->nTableMask];
+				t = ht->pListHead;
+				while (t) {
+					if (t == q) {
+						before = 1;
+						break;
+					}
+					if (t == p) {
+						break;
+					}
+					t = t->pListNext;
+				}
+
 				while (q != NULL) {
-					if (q == p) {
-						found = 1;
-					} else if (q->h == h && q->nKeyLength == str_length && 
+					if (q->h == h && q->nKeyLength == str_length && 
 					           memcmp(q->arKey, str_index, str_length) == 0) {
-					    if (found) {
+					    if (before) {
 							if (mode & HASH_UPDATE_KEY_IF_BEFORE) {
 								break;
 							} else {
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 08:01:28 2024 UTC