]> granicus.if.org Git - php/commitdiff
Fix memory leak when dereferencing reference with refcount 1
authorBob Weinand <bobwei9@hotmail.com>
Sun, 4 Jan 2015 23:28:53 +0000 (00:28 +0100)
committerBob Weinand <bobwei9@hotmail.com>
Sun, 4 Jan 2015 23:28:53 +0000 (00:28 +0100)
Zend/zend_variables.c

index 56b9b675986334532cbb3aa5e70cd5c90e4fcc0e..b476bd9f8d2b56423cc69c4cc123928e73b78509 100644 (file)
@@ -205,7 +205,9 @@ ZEND_API void zval_add_ref(zval *p)
 {
        if (Z_REFCOUNTED_P(p)) {
                if (Z_ISREF_P(p) && Z_REFCOUNT_P(p) == 1) {
+                       zend_reference *ref = Z_REF_P(p);
                        ZVAL_COPY(p, Z_REFVAL_P(p));
+                       efree(ref);
                } else {
                        Z_ADDREF_P(p);
                }