summaryrefslogtreecommitdiff
path: root/embed.fnc
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2021-09-11 10:47:10 +0000
committerNicholas Clark <nick@ccl4.org>2021-09-23 15:27:34 +0000
commitd978f0698f3cdb11f60c849e5ec37c62f82c731a (patch)
treee494de27332b6ebb1fa2daace6a0527c747c47b1 /embed.fnc
parent07024caa60f04ae203801d222536bfdad4caf7e8 (diff)
downloadperl-d978f0698f3cdb11f60c849e5ec37c62f82c731a.tar.gz
Don't leak in hv_common when croaking about PL_strtab
hv_common can perform read-only actions on PL_strtab, but not write actions. The code that detects this and croaks had been just after the allocation of a new HE *, and hence was leaking it. Re-order the code to avoid the leak. The leak usually wasn't noticeable as HEs are allocated from arenas, and arenas are correctly freed during full destruction. However, building with -DPURIFY replaces arenas with individual allocations, making this leak visible. It's unlikely to have been hit by any production code, but it was causing leaks during the regression tests. Also change embed.fnc so that S_new_HE's prototype is not declared under -DPURIFY, as the static function itself is not defined in this case. This fixes a compiler warning.
Diffstat (limited to 'embed.fnc')
-rw-r--r--embed.fnc2
1 files changed, 2 insertions, 0 deletions
diff --git a/embed.fnc b/embed.fnc
index 003519ba8d..8c9a312329 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -2882,7 +2882,9 @@ po |SV* |hfree_next_entry |NN HV *hv|NN STRLEN *indexp
S |void |hsplit |NN HV *hv|STRLEN const oldsize|STRLEN newsize
S |void |hv_free_entries|NN HV *hv
S |SV* |hv_free_ent_ret|NN HV *hv|NN HE *entry
+#if !defined(PURIFY)
SR |HE* |new_he
+#endif
SaTR |HEK* |save_hek_flags |NN const char *str|I32 len|U32 hash|int flags
ST |void |hv_magic_check |NN HV *hv|NN bool *needs_copy|NN bool *needs_store
S |void |unshare_hek_or_pvn|NULLOK const HEK* hek|NULLOK const char* str|I32 len|U32 hash