Skip to content

Commit ff67e39

Browse files
committed
Adjust lineno on PHP 7 for first instruction
Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
1 parent 05be061 commit ff67e39

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

zend_abstract_interface/interceptor/php7/interceptor.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,10 @@ static inline bool zai_is_func_recv_opcode(zend_uchar opcode) {
113113
// Replace EXT_NOP by EXT_STMT, then move it after RECV ops if possible
114114
void zai_interceptor_op_array_pass_two(zend_op_array *op_array) {
115115
zend_op *opcodes = op_array->opcodes;
116-
for (zend_op *cur = opcodes, *last = cur + op_array->last; cur < last; ++cur) {
116+
for (zend_op *cur = opcodes, *last = cur + op_array->last; cur < last - 1; ++cur) {
117117
if (cur->opcode == ZEND_EXT_STMT && cur->extended_value == ZAI_INTERCEPTOR_CUSTOM_EXT) {
118118
cur->opcode = ZEND_EXT_NOP;
119+
cur->lineno = (cur + 1)->lineno; // adjust to actual lineno of next op
119120
break;
120121
}
121122
}
@@ -132,6 +133,7 @@ void zai_interceptor_op_array_pass_two(zend_op_array *op_array) {
132133
if (--i > nop_i) {
133134
memmove(&opcodes[nop_i], &opcodes[nop_i + 1], (i - nop_i) * sizeof(zend_op));
134135
zai_set_ext_nop(&opcodes[i]);
136+
opcodes[i].lineno = opcodes[i + 1].lineno;
135137
}
136138

137139
// For generators we need our own temporary to store a constant array which is converted to an iterator

0 commit comments

Comments
 (0)