Merge branch 'PHP-8.1'

* PHP-8.1:
  Handle holes in zend_get_opcode_id()
This commit is contained in:
Nikita Popov 2021-12-30 16:56:10 +01:00
commit 55a4bae546
2 changed files with 4 additions and 2 deletions

View File

@ -2651,7 +2651,8 @@ function gen_vm($def, $skel) {
fputs($f, "ZEND_API zend_uchar zend_get_opcode_id(const char *name, size_t length) {\n");
fputs($f, "\tzend_uchar opcode;\n");
fputs($f, "\tfor (opcode = 0; opcode < (sizeof(zend_vm_opcodes_names) / sizeof(zend_vm_opcodes_names[0])) - 1; opcode++) {\n");
fputs($f, "\t\tif (strncmp(zend_vm_opcodes_names[opcode], name, length) == 0) {\n");
fputs($f, "\t\tconst char *opcode_name = zend_vm_opcodes_names[opcode];\n");
fputs($f, "\t\tif (opcode_name && strncmp(opcode_name, name, length) == 0) {\n");
fputs($f, "\t\t\treturn opcode;\n");
fputs($f, "\t\t}\n");
fputs($f, "\t}\n");

View File

@ -449,7 +449,8 @@ ZEND_API uint32_t ZEND_FASTCALL zend_get_opcode_flags(zend_uchar opcode) {
ZEND_API zend_uchar zend_get_opcode_id(const char *name, size_t length) {
zend_uchar opcode;
for (opcode = 0; opcode < (sizeof(zend_vm_opcodes_names) / sizeof(zend_vm_opcodes_names[0])) - 1; opcode++) {
if (strncmp(zend_vm_opcodes_names[opcode], name, length) == 0) {
const char *opcode_name = zend_vm_opcodes_names[opcode];
if (opcode_name && strncmp(opcode_name, name, length) == 0) {
return opcode;
}
}