diff options
author | Paul "LeoNerd" Evans <leonerd@leonerd.org.uk> | 2022-12-14 12:35:57 +0000 |
---|---|---|
committer | Yves Orton <demerphq@gmail.com> | 2023-02-07 19:58:06 +0800 |
commit | 70bac31a4f4e90f39d9876a34715f0c83d2684dd (patch) | |
tree | 6782422bc597e3f7a5f660b0a7266cf12f4e3ff9 /util.c | |
parent | aa2d00d7d06d0ec6110c4351b635728dfa53bc81 (diff) | |
download | perl-70bac31a4f4e90f39d9876a34715f0c83d2684dd.tar.gz |
Avoid a use-after-free warning by converting a pointer to a UV for debug print purposes before we call realloc() on it
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -274,6 +274,7 @@ Perl_safesysrealloc(Malloc_t where,MEM_SIZE size) #ifdef DEBUGGING if ((SSize_t)size < 0) Perl_croak_nocontext("panic: realloc, size=%" UVuf, (UV)size); + UV was_where = PTR2UV(where); #endif #ifdef PERL_DEBUG_READONLY_COW if ((ptr = mmap(0, size, PROT_READ|PROT_WRITE, @@ -326,7 +327,7 @@ Perl_safesysrealloc(Malloc_t where,MEM_SIZE size) /* In particular, must do that fixup above before logging anything via *printf(), as it can reallocate memory, which can cause SEGVs. */ - DEBUG_m(PerlIO_printf(Perl_debug_log, "0x%" UVxf ": (%05ld) rfree\n",PTR2UV(where),(long)PL_an++)); + DEBUG_m(PerlIO_printf(Perl_debug_log, "0x%" UVxf ": (%05ld) rfree\n",was_where,(long)PL_an++)); DEBUG_m(PerlIO_printf(Perl_debug_log, "0x%" UVxf ": (%05ld) realloc %ld bytes\n",PTR2UV(ptr),(long)PL_an++,(long)size)); if (ptr == NULL) { |