Skip to content

Commit 50cce5e

Browse files
committed
Avoid reliance on arena details on phpdbg oplog
Instead of guessing what the address of the first arena allocation is going to be, embed the sentinel in the oplog_list structure directly.
1 parent c0bf3bc commit 50cce5e

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

sapi/phpdbg/phpdbg.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -449,14 +449,12 @@ static PHP_FUNCTION(phpdbg_start_oplog)
449449

450450
if (!prev) {
451451
PHPDBG_G(oplog_arena) = zend_arena_create(64 * 1024);
452-
453-
PHPDBG_G(oplog_cur) = ((phpdbg_oplog_entry *) zend_arena_alloc(&PHPDBG_G(oplog_arena), sizeof(phpdbg_oplog_entry))) + 1;
454-
PHPDBG_G(oplog_cur)->next = NULL;
455452
}
456453

457454
PHPDBG_G(oplog_list) = emalloc(sizeof(phpdbg_oplog_list));
458455
PHPDBG_G(oplog_list)->prev = prev;
459-
PHPDBG_G(oplog_list)->start = PHPDBG_G(oplog_cur);
456+
PHPDBG_G(oplog_cur) = &PHPDBG_G(oplog_list)->start;
457+
PHPDBG_G(oplog_cur)->next = NULL;
460458
}
461459

462460
static zend_always_inline zend_bool phpdbg_is_ignored_opcode(zend_uchar opcode) {
@@ -633,7 +631,7 @@ static PHP_FUNCTION(phpdbg_end_oplog)
633631
return;
634632
}
635633

636-
cur = PHPDBG_G(oplog_list)->start;
634+
cur = PHPDBG_G(oplog_list)->start.next;
637635
prev = PHPDBG_G(oplog_list)->prev;
638636

639637
efree(PHPDBG_G(oplog_list));

sapi/phpdbg/phpdbg_opcode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct _phpdbg_oplog_entry {
4040
typedef struct _phpdbg_oplog_list phpdbg_oplog_list;
4141
struct _phpdbg_oplog_list {
4242
phpdbg_oplog_list *prev;
43-
phpdbg_oplog_entry *start;
43+
phpdbg_oplog_entry start; /* Only "next" member used. */
4444
};
4545

4646
#endif /* PHPDBG_OPCODE_H */

0 commit comments

Comments
 (0)