]> granicus.if.org Git - php/commitdiff
Fix a leak
authorVektah <adam.scarr@99designs.com>
Fri, 13 Mar 2015 04:54:30 +0000 (15:54 +1100)
committerVektah <adam.scarr@99designs.com>
Fri, 13 Mar 2015 04:54:30 +0000 (15:54 +1100)
ext/spl/spl_observer.c

index 6bd0d9011ca036421067cf2ab01872f2599384a5..2b50319a62933bdf55015a1b65c9b9ffbc5b5b6a 100644 (file)
@@ -109,7 +109,7 @@ void spl_SplOjectStorage_free_storage(void *object TSRMLS_DC) /* {{{ */
                efree(intern->debug_info);
        }
 
-       if (intern->gcdata_len > 0) {
+       if (intern->gcdata != NULL) {
                efree(intern->gcdata);
        }
 
@@ -378,10 +378,6 @@ static HashTable *spl_object_storage_get_gc(zval *obj, zval ***table, int *n TSR
        long requiredLength = intern->storage.nNumOfElements * 2;
 
        if (requiredLength > intern->gcdata_len) {
-               if (intern->gcdata_len > 0) {
-                       efree(intern->gcdata);
-               }
-
                intern->gcdata = (zval**)erealloc(intern->gcdata, sizeof(zval*) * requiredLength);
                intern->gcdata_len = requiredLength;
        }
@@ -394,7 +390,7 @@ static HashTable *spl_object_storage_get_gc(zval *obj, zval ***table, int *n TSR
        }
 
        *table = intern->gcdata;
-       *n = intern->gcdata_len;
+       *n = i;
 
        return std_object_handlers.get_properties(obj TSRMLS_CC);
 }