Skip to content

Commit

Permalink
Fixed memory leak in ext/spl/tests/spl_autoload_bug48541.phpt
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Apr 27, 2010
1 parent 8546225 commit 9424d42
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ext/spl/php_spl.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,14 @@ PHP_FUNCTION(spl_autoload_register)
}
}

zend_hash_add(SPL_G(autoload_functions), lc_name, func_name_len+1, &alfi.func_ptr, sizeof(autoload_func_info), NULL);
if (zend_hash_add(SPL_G(autoload_functions), lc_name, func_name_len+1, &alfi.func_ptr, sizeof(autoload_func_info), NULL) == FAILURE) {
if (obj_ptr && !(alfi.func_ptr->common.fn_flags & ZEND_ACC_STATIC)) {
Z_DELREF_P(alfi.obj);
}
if (alfi.closure) {
Z_DELREF_P(alfi.closure);
}
}
if (prepend && SPL_G(autoload_functions)->nNumOfElements > 1) {
/* Move the newly created element to the head of the hashtable */
HT_MOVE_TAIL_TO_HEAD(SPL_G(autoload_functions));
Expand Down

0 comments on commit 9424d42

Please sign in to comment.