From a461f1742a31d3a0e87885dfcd1e7aff154f96fa Mon Sep 17 00:00:00 2001 From: jvoisin Date: Thu, 9 Aug 2018 15:47:23 +0200 Subject: Fix a possible crash/hang in floppy-comparison This is in the same spirit than the previous commit --- src/sp_sloppy.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/sp_sloppy.c b/src/sp_sloppy.c index d5ccd6b..9057571 100644 --- a/src/sp_sloppy.c +++ b/src/sp_sloppy.c @@ -1,9 +1,9 @@ #include "sp_sloppy.h" -ZEND_API zend_op_array* (*zend_compile_file_default)( - zend_file_handle* file_handle, int type) = NULL; -ZEND_API zend_op_array* (*zend_compile_string_default)(zval* source_string, - char* filename) = NULL; +ZEND_API zend_op_array* (*orig_zend_compile_file)(zend_file_handle* file_handle, + int type) = NULL; +ZEND_API zend_op_array* (*orig_zend_compile_string)(zval* source_string, + char* filename) = NULL; static void modify_opcode(zend_op_array* opline) { if (NULL != opline) { @@ -21,22 +21,26 @@ static void modify_opcode(zend_op_array* opline) { } ZEND_API zend_op_array* sp_compile_string(zval* source_string, char* filename) { - zend_op_array* opline = zend_compile_string_default(source_string, filename); + zend_op_array* opline = orig_zend_compile_string(source_string, filename); modify_opcode(opline); return opline; } ZEND_API zend_op_array* sp_compile_file(zend_file_handle* file_handle, int type) { - zend_op_array* opline = zend_compile_file_default(file_handle, type); + zend_op_array* opline = orig_zend_compile_file(file_handle, type); modify_opcode(opline); return opline; } void hook_sloppy() { - zend_compile_file_default = zend_compile_file; - zend_compile_file = sp_compile_file; + if (NULL == orig_zend_compile_file) { + orig_zend_compile_file = zend_compile_file; + zend_compile_file = sp_compile_file; + } - zend_compile_string_default = zend_compile_string; - zend_compile_string = sp_compile_string; + if (NULL == orig_zend_compile_string) { + orig_zend_compile_string = zend_compile_string; + zend_compile_string = sp_compile_string; + } } -- cgit v1.3