Skip to content
This repository has been archived by the owner on Oct 14, 2023. It is now read-only.

Commit

Permalink
Fix memory leak in php 7.0.7, use same array resizing as unserialize
Browse files Browse the repository at this point in the history
Affected with --enable-debug --enable-maintainer zts
  • Loading branch information
TysonAndre committed Jul 18, 2016
1 parent 3bea918 commit 871094d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions igbinary.c
Original file line number Diff line number Diff line change
Expand Up @@ -2042,7 +2042,7 @@ inline static int igbinary_unserialize_array(struct igbinary_unserialize_data *i
}
}
if ((flags & WANT_OBJECT) == 0) {
array_init_size(z_deref, n + 1);
array_init_size(z_deref, n);
/* add the new array to the list of unserialized references */
if (igsd_append_ref(igsd, z) == SIZE_MAX) {
return 1;
Expand All @@ -2055,7 +2055,11 @@ inline static int igbinary_unserialize_array(struct igbinary_unserialize_data *i
}

h = HASH_OF(z_deref);

if ((flags & WANT_OBJECT) != 0) {
/* Copied from var_unserializer.re. Need to ensure that IGB_REF_VAL doesn't point to invalid data. */
/* Worst case: All n of the added properties are dynamic. */
zend_hash_extend(h, zend_hash_num_elements(h) + n, (h->u.flags & HASH_FLAG_PACKED));
}
for (i = 0; i < n; i++) {
key = NULL;

Expand Down

0 comments on commit 871094d

Please sign in to comment.