From 34a91e38af39f19cf33d993a6979805ef2143359 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sun, 31 Jul 2022 17:50:25 +0100 Subject: [PATCH] phpdbg few fixes, mostly printf-like format issues due to C str -> zend_string mismatches. annotate the allocator wrapper. --- Zend/zend_alloc.h | 2 +- sapi/phpdbg/phpdbg.c | 2 +- sapi/phpdbg/phpdbg_bp.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Zend/zend_alloc.h b/Zend/zend_alloc.h index 664628eeacd78..3df0a3ba719de 100644 --- a/Zend/zend_alloc.h +++ b/Zend/zend_alloc.h @@ -243,7 +243,7 @@ typedef struct _zend_mm_heap zend_mm_heap; ZEND_API zend_mm_heap *zend_mm_startup(void); ZEND_API void zend_mm_shutdown(zend_mm_heap *heap, bool full_shutdown, bool silent); -ZEND_API ZEND_ATTRIBUTE_MALLOC void* ZEND_FASTCALL _zend_mm_alloc(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); +ZEND_API ZEND_ATTRIBUTE_MALLOC void* ZEND_FASTCALL _zend_mm_alloc(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_ALLOC_SIZE(2); ZEND_API void ZEND_FASTCALL _zend_mm_free(zend_mm_heap *heap, void *p ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); ZEND_API void* ZEND_FASTCALL _zend_mm_realloc(zend_mm_heap *heap, void *p, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); ZEND_API void* ZEND_FASTCALL _zend_mm_realloc2(zend_mm_heap *heap, void *p, size_t size, size_t copy_size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC); diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index 440f526f2bed5..52eed52fbacb4 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -1076,7 +1076,7 @@ void phpdbg_sighup_handler(int sig) /* {{{ */ } /* }}} */ #endif -void *phpdbg_malloc_wrapper(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) /* {{{ */ +ZEND_ATTRIBUTE_MALLOC ZEND_ATTRIBUTE_ALLOC_SIZE(1) void *phpdbg_malloc_wrapper(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) /* {{{ */ { return _zend_mm_alloc(zend_mm_get_heap(), size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC); } /* }}} */ diff --git a/sapi/phpdbg/phpdbg_bp.c b/sapi/phpdbg/phpdbg_bp.c index a79efef4161bd..a20b4bd65db92 100644 --- a/sapi/phpdbg/phpdbg_bp.c +++ b/sapi/phpdbg/phpdbg_bp.c @@ -315,7 +315,7 @@ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, size_t path_len, ze ZEND_HASH_MAP_FOREACH_STR_KEY(&PHPDBG_G(file_sources), file) { HashTable *fileht; - phpdbg_debug("Compare against loaded %s\n", file); + phpdbg_debug("Compare against loaded %s\n", ZSTR_VAL(file)); if (!(pending = ((fileht = phpdbg_resolve_pending_file_break_ex(ZSTR_VAL(file), ZSTR_LEN(file), path_str, broken)) == NULL))) { new_break = *(phpdbg_breakfile_t *) zend_hash_index_find_ptr(fileht, line_num); @@ -378,7 +378,7 @@ PHPDBG_API HashTable *phpdbg_resolve_pending_file_break_ex(const char *file, uin PHPDBG_G(flags) &= ~PHPDBG_HAS_PENDING_FILE_BP; } - phpdbg_debug("compiled file: %s, cur bp file: %s\n", file, cur); + phpdbg_debug("compiled file: %s, cur bp file: %s\n", file, ZSTR_VAL(cur)); return master; } @@ -395,7 +395,7 @@ PHPDBG_API void phpdbg_resolve_pending_file_break(const char *file) /* {{{ */ phpdbg_debug("was compiled: %s\n", file); ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], cur, fileht) { - phpdbg_debug("check bp: %s\n", cur); + phpdbg_debug("check bp: %s\n", ZSTR_VAL(cur)); phpdbg_resolve_pending_file_break_ex(file, filelen, cur, fileht); } ZEND_HASH_FOREACH_END();