diff options
author | Haitao Lv <i@lvht.net> | 2018-02-12 09:25:31 +0800 |
---|---|---|
committer | Joe <krakjoe@php.net> | 2018-02-12 09:27:55 +0100 |
commit | 5206f79987e8db041e5580f70f60ad0ed2d1cad7 (patch) | |
tree | b4f26a348781697b0bfc81030041a4fde96ff791 /Zend/zend_vm_gen.php | |
parent | 3253057021143c7336d03265682200482e5bf996 (diff) | |
download | php-git-5206f79987e8db041e5580f70f60ad0ed2d1cad7.tar.gz |
fix unknown opcode overflow error
Diffstat (limited to 'Zend/zend_vm_gen.php')
-rw-r--r-- | Zend/zend_vm_gen.php | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Zend/zend_vm_gen.php b/Zend/zend_vm_gen.php index c694c94287..588af86aea 100644 --- a/Zend/zend_vm_gen.php +++ b/Zend/zend_vm_gen.php @@ -2396,7 +2396,8 @@ function gen_vm($def, $skel) { // Insert header out($f, HEADER_TEXT); fputs($f,"#include <stdio.h>\n"); - fputs($f,"#include <zend.h>\n\n"); + fputs($f,"#include <zend.h>\n"); + fputs($f,"#include <zend_vm_opcodes.h>\n\n"); fputs($f,"static const char *zend_vm_opcodes_names[".($max_opcode + 1)."] = {\n"); for ($i = 0; $i <= $max_opcode; $i++) { @@ -2411,10 +2412,16 @@ function gen_vm($def, $skel) { fputs($f, "};\n\n"); fputs($f, "ZEND_API const char* ZEND_FASTCALL zend_get_opcode_name(zend_uchar opcode) {\n"); + fputs($f, "\tif (UNEXPECTED(opcode > ZEND_VM_LAST_OPCODE)) {\n"); + fputs($f, "\t\treturn NULL;\n"); + fputs($f, "\t}\n"); fputs($f, "\treturn zend_vm_opcodes_names[opcode];\n"); fputs($f, "}\n"); fputs($f, "ZEND_API uint32_t ZEND_FASTCALL zend_get_opcode_flags(zend_uchar opcode) {\n"); + fputs($f, "\tif (UNEXPECTED(opcode > ZEND_VM_LAST_OPCODE)) {\n"); + fputs($f, "\t\topcode = ZEND_NOP;\n"); + fputs($f, "\t}\n"); fputs($f, "\treturn zend_vm_opcodes_flags[opcode];\n"); fputs($f, "}\n"); |