Hello internals,

  according to our manual index values are either strings or integers. In case
of strings which represent integers they are also handled as integers. Bug
21918 now shows that this currently only works for zero and positive index
values. The attached patch would fix this.

-- 
Best regards,
 Marcus                          mailto:[EMAIL PROTECTED]
Index: Zend/zend_hash.h
===================================================================
RCS file: /repository/ZendEngine2/zend_hash.h,v
retrieving revision 1.72
diff -u -p -d -r1.72 zend_hash.h
--- Zend/zend_hash.h    23 Jul 2003 08:56:34 -0000      1.72
+++ Zend/zend_hash.h    11 Aug 2003 01:27:16 -0000
@@ -287,8 +287,11 @@ END_EXTERN_C()
 #define HANDLE_NUMERIC(key, length, func) {                                           
                                                 \
        register char *tmp=key;                                                        
                                                                 \
                                                                                       
                                                                                       
  \
+       if (*tmp=='-') {                                                               
                                                                         \
+               tmp++;                                                                 
                                                                                 \
+       }                                                                              
                                                                                       
  \
        if ((*tmp>='0' && *tmp<='9')) do { /* possibly a numeric index */              
                         \
-               char *end=tmp+length-1;                                                
                                                                 \
+               char *end=key+length-1;                                                
                                                                 \
                ulong idx;                                                             
                                                                                 \
                                                                                       
                                                                                       
  \
                if (*tmp++=='0' && length>2) { /* don't accept numbers with leading 
zeros */    \
@@ -301,9 +304,16 @@ END_EXTERN_C()
                        tmp++;                                                         
                                                                                 \
                }                                                                      
                                                                                       
  \
                if (tmp==end && *tmp=='\0') { /* a numeric index */                    
                                         \
-                       idx = strtol(key, NULL, 10);                                   
                                                         \
-                       if (idx!=LONG_MAX) {                                           
                                                                 \
-                               return func;                                           
                                                                         \
+                       if (*key=='-') {                                               
                                                                         \
+                               idx = strtol(key, NULL, 10);                           
                                                         \
+                               if (idx!=LONG_MIN) {                                   
                                                                 \
+                                       return func;                                   
                                                                         \
+                               }                                                      
                                                                                       
  \
+                       } else {                                                       
                                                                                 \
+                               idx = strtol(key, NULL, 10);                           
                                                         \
+                               if (idx!=LONG_MAX) {                                   
                                                                 \
+                                       return func;                                   
                                                                         \
+                               }                                                      
                                                                                       
  \
                        }                                                              
                                                                                       
  \
                }                                                                      
                                                                                       
  \
        } while (0);                                                                   
                                                                         \
-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to