diff options
| author | jvoisin | 2018-08-09 15:47:23 +0200 |
|---|---|---|
| committer | jvoisin | 2018-08-09 15:47:23 +0200 |
| commit | a461f1742a31d3a0e87885dfcd1e7aff154f96fa (patch) | |
| tree | 7b98f9eae4734f87a67c5d878c3f8aba295d2592 /src/sp_sloppy.c | |
| parent | 00160b4430a7a02656fc07a7752d1c2d83e80871 (diff) | |
Fix a possible crash/hang in floppy-comparison
This is in the same spirit than the previous commit
Diffstat (limited to 'src/sp_sloppy.c')
| -rw-r--r-- | src/sp_sloppy.c | 24 |
1 files changed, 14 insertions, 10 deletions
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 @@ | |||
| 1 | #include "sp_sloppy.h" | 1 | #include "sp_sloppy.h" |
| 2 | 2 | ||
| 3 | ZEND_API zend_op_array* (*zend_compile_file_default)( | 3 | ZEND_API zend_op_array* (*orig_zend_compile_file)(zend_file_handle* file_handle, |
| 4 | zend_file_handle* file_handle, int type) = NULL; | 4 | int type) = NULL; |
| 5 | ZEND_API zend_op_array* (*zend_compile_string_default)(zval* source_string, | 5 | ZEND_API zend_op_array* (*orig_zend_compile_string)(zval* source_string, |
| 6 | char* filename) = NULL; | 6 | char* filename) = NULL; |
| 7 | 7 | ||
| 8 | static void modify_opcode(zend_op_array* opline) { | 8 | static void modify_opcode(zend_op_array* opline) { |
| 9 | if (NULL != opline) { | 9 | if (NULL != opline) { |
| @@ -21,22 +21,26 @@ static void modify_opcode(zend_op_array* opline) { | |||
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | ZEND_API zend_op_array* sp_compile_string(zval* source_string, char* filename) { | 23 | ZEND_API zend_op_array* sp_compile_string(zval* source_string, char* filename) { |
| 24 | zend_op_array* opline = zend_compile_string_default(source_string, filename); | 24 | zend_op_array* opline = orig_zend_compile_string(source_string, filename); |
| 25 | modify_opcode(opline); | 25 | modify_opcode(opline); |
| 26 | return opline; | 26 | return opline; |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | ZEND_API zend_op_array* sp_compile_file(zend_file_handle* file_handle, | 29 | ZEND_API zend_op_array* sp_compile_file(zend_file_handle* file_handle, |
| 30 | int type) { | 30 | int type) { |
| 31 | zend_op_array* opline = zend_compile_file_default(file_handle, type); | 31 | zend_op_array* opline = orig_zend_compile_file(file_handle, type); |
| 32 | modify_opcode(opline); | 32 | modify_opcode(opline); |
| 33 | return opline; | 33 | return opline; |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | void hook_sloppy() { | 36 | void hook_sloppy() { |
| 37 | zend_compile_file_default = zend_compile_file; | 37 | if (NULL == orig_zend_compile_file) { |
| 38 | zend_compile_file = sp_compile_file; | 38 | orig_zend_compile_file = zend_compile_file; |
| 39 | zend_compile_file = sp_compile_file; | ||
| 40 | } | ||
| 39 | 41 | ||
| 40 | zend_compile_string_default = zend_compile_string; | 42 | if (NULL == orig_zend_compile_string) { |
| 41 | zend_compile_string = sp_compile_string; | 43 | orig_zend_compile_string = zend_compile_string; |
| 44 | zend_compile_string = sp_compile_string; | ||
| 45 | } | ||
| 42 | } | 46 | } |
