Skip to content

Instantly share code, notes, and snippets.

@t3rmin4t0r
Created October 30, 2010 19:15
Show Gist options
  • Save t3rmin4t0r/655644 to your computer and use it in GitHub Desktop.
Save t3rmin4t0r/655644 to your computer and use it in GitHub Desktop.
Zend CG(open_files)
Culprit - zend_op_array *compile_filename(int type, zval *filename TSRMLS_DC)
====================PHP 5.1====================
ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle TSRMLS_DC)
{
zend_llist_del_element(&CG(open_files), file_handle, (int (*)(void *, void *)) zend_compare_file_handles);
}
...
retval = zend_compile_file(&file_handle, type TSRMLS_CC);
if (retval && file_handle.handle.stream.handle) {
...
}
zend_destroy_file_handle(&file_handle TSRMLS_CC);
====================PHP 5.2 & 5.3====================
ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle TSRMLS_DC)
{
zend_llist_del_element(&CG(open_files), file_handle, (int (*)(void *, void *)) zend_compare_file_handles);
/* zend_file_handle_dtor() operates on the copy, so we have to NULLify the original here */
file_handle->opened_path = NULL;
if (file_handle->free_filename) {
file_handle->filename = NULL;
}
}
...
retval = zend_compile_file(&file_handle, type TSRMLS_CC);
...
zend_destroy_file_handle(&file_handle TSRMLS_CC);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment