Skip to content

Commit 5f1311a

Browse files
nielsdosGirgias
authored andcommitted
Fix undefined behaviour in phpdbg_load_module_or_extension
If zend_register_module_ex were to return NULL, then module_entry will be set to NULL, and the if's body will load module_entry->name. Since module_entry is NULL, loading the name would cause a NULL pointer dereference. However, since a NULL pointer dereference is undefined behaviour, the compiler is free to remove the check. Fix it by using *name instead of module_entry->name. Closes GH-10157 Signed-off-by: George Peter Banyard <girgias@php.net>
1 parent bbad29b commit 5f1311a

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ PHP NEWS
1717
. Fix inverted bailout value in zend_runtime_jit() (Max Kellermann).
1818
. Fix access to uninitialized variable in accel_preload(). (nielsdos)
1919

20+
- PHPDBG:
21+
. Fix undefined behaviour in phpdbg_load_module_or_extension(). (nielsdos)
22+
2023
- TSRM:
2124
. Fixed Windows shmget() wrt. IPC_PRIVATE. (Tyson Andre)
2225

sapi/phpdbg/phpdbg_prompt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ PHPDBG_API const char *phpdbg_load_module_or_extension(char **path, const char *
13211321
module_entry->handle = handle;
13221322

13231323
if ((module_entry = zend_register_module_ex(module_entry)) == NULL) {
1324-
phpdbg_error("Unable to register module %s", module_entry->name);
1324+
phpdbg_error("Unable to register module %s", *name);
13251325

13261326
goto quit;
13271327
}

0 commit comments

Comments
 (0)