]> granicus.if.org Git - php/commitdiff
Avoid reliance on arena details on phpdbg oplog
authorNikita Popov <nikita.ppv@gmail.com>
Fri, 28 Jun 2019 10:32:54 +0000 (12:32 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 28 Jun 2019 12:47:42 +0000 (14:47 +0200)
Instead of guessing what the address of the first arena allocation
is going to be, embed the sentinel in the oplog_list structure
directly.

sapi/phpdbg/phpdbg.c
sapi/phpdbg/phpdbg_opcode.h

index 463749ea3acb4f50af1b027015a22214fadf7134..67cefc75f23ab97caf186ee11b8aa92d496f8614 100644 (file)
@@ -449,14 +449,12 @@ static PHP_FUNCTION(phpdbg_start_oplog)
 
        if (!prev) {
                PHPDBG_G(oplog_arena) = zend_arena_create(64 * 1024);
-
-               PHPDBG_G(oplog_cur) = ((phpdbg_oplog_entry *) zend_arena_alloc(&PHPDBG_G(oplog_arena), sizeof(phpdbg_oplog_entry))) + 1;
-               PHPDBG_G(oplog_cur)->next = NULL;
        }
 
        PHPDBG_G(oplog_list) = emalloc(sizeof(phpdbg_oplog_list));
        PHPDBG_G(oplog_list)->prev = prev;
-       PHPDBG_G(oplog_list)->start = PHPDBG_G(oplog_cur);
+       PHPDBG_G(oplog_cur) = &PHPDBG_G(oplog_list)->start;
+       PHPDBG_G(oplog_cur)->next = NULL;
 }
 
 static zend_always_inline zend_bool phpdbg_is_ignored_opcode(zend_uchar opcode) {
@@ -633,7 +631,7 @@ static PHP_FUNCTION(phpdbg_end_oplog)
                return;
        }
 
-       cur = PHPDBG_G(oplog_list)->start;
+       cur = PHPDBG_G(oplog_list)->start.next;
        prev = PHPDBG_G(oplog_list)->prev;
 
        efree(PHPDBG_G(oplog_list));
index f84862fbae5e8aa8aa82339ae236fdf45ad90608..b9e2fa506cb28de126cf9f4929978322584cf8c3 100644 (file)
@@ -40,7 +40,7 @@ struct _phpdbg_oplog_entry {
 typedef struct _phpdbg_oplog_list phpdbg_oplog_list;
 struct _phpdbg_oplog_list {
        phpdbg_oplog_list *prev;
-       phpdbg_oplog_entry *start;
+       phpdbg_oplog_entry start; /* Only "next" member used. */
 };
 
 #endif /* PHPDBG_OPCODE_H */