]> granicus.if.org Git - php/commitdiff
MF51: fix #37057 (xmlrpc_decode() may produce arrays with numeric string keys which...
authorAntony Dovgal <tony2001@php.net>
Wed, 12 Apr 2006 15:14:43 +0000 (15:14 +0000)
committerAntony Dovgal <tony2001@php.net>
Wed, 12 Apr 2006 15:14:43 +0000 (15:14 +0000)
ext/xmlrpc/xmlrpc-epi-php.c

index 9283db1e4df0a17488f6cc65a274cddbd100b5c6..49abfc20bb396af7cb3d0ec546db6343b32692de 100644 (file)
@@ -300,7 +300,13 @@ static int add_zval(zval* list, const char* id, zval** val)
 {
        if (list && val) {
                if (id) {
-                       return zend_hash_update(Z_ARRVAL_P(list), (char*) id, strlen(id) + 1, (void *) val, sizeof(zval **), NULL);
+                       int id_len = strlen(id);
+                       if (!(id_len > 1 && id[0] == '0') && is_numeric_string((char *)id, id_len, NULL, NULL, 0) == IS_LONG) {
+                               long index = strtol(id, NULL, 0);
+                               return zend_hash_index_update(Z_ARRVAL_P(list), index, (void *) val, sizeof(zval **), NULL);
+                       } else {
+                               return zend_hash_update(Z_ARRVAL_P(list), (char*) id, strlen(id) + 1, (void *) val, sizeof(zval **), NULL);
+                       }
                } else {
                        return zend_hash_next_index_insert(Z_ARRVAL_P(list), (void *) val, sizeof(zval **), NULL); 
                }