Skip to content

Commit 55a4bae

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Handle holes in zend_get_opcode_id()
2 parents a0be3f8 + b63e4cf commit 55a4bae

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Zend/zend_vm_gen.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2651,7 +2651,8 @@ function gen_vm($def, $skel) {
26512651
fputs($f, "ZEND_API zend_uchar zend_get_opcode_id(const char *name, size_t length) {\n");
26522652
fputs($f, "\tzend_uchar opcode;\n");
26532653
fputs($f, "\tfor (opcode = 0; opcode < (sizeof(zend_vm_opcodes_names) / sizeof(zend_vm_opcodes_names[0])) - 1; opcode++) {\n");
2654-
fputs($f, "\t\tif (strncmp(zend_vm_opcodes_names[opcode], name, length) == 0) {\n");
2654+
fputs($f, "\t\tconst char *opcode_name = zend_vm_opcodes_names[opcode];\n");
2655+
fputs($f, "\t\tif (opcode_name && strncmp(opcode_name, name, length) == 0) {\n");
26552656
fputs($f, "\t\t\treturn opcode;\n");
26562657
fputs($f, "\t\t}\n");
26572658
fputs($f, "\t}\n");

Zend/zend_vm_opcodes.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,8 @@ ZEND_API uint32_t ZEND_FASTCALL zend_get_opcode_flags(zend_uchar opcode) {
449449
ZEND_API zend_uchar zend_get_opcode_id(const char *name, size_t length) {
450450
zend_uchar opcode;
451451
for (opcode = 0; opcode < (sizeof(zend_vm_opcodes_names) / sizeof(zend_vm_opcodes_names[0])) - 1; opcode++) {
452-
if (strncmp(zend_vm_opcodes_names[opcode], name, length) == 0) {
452+
const char *opcode_name = zend_vm_opcodes_names[opcode];
453+
if (opcode_name && strncmp(opcode_name, name, length) == 0) {
453454
return opcode;
454455
}
455456
}

0 commit comments

Comments
 (0)