summaryrefslogtreecommitdiff
path: root/cop.h
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-12-20 11:15:29 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-12-20 11:15:29 +0000
commit63031dafabc5d083e95e183670b541c828379c76 (patch)
tree97ed783b9091b2b1b8391d5aec301b4237f85cd7 /cop.h
parent7bf061987421c117ea5f8db9475ff899f75b9098 (diff)
downloadperl-63031dafabc5d083e95e183670b541c828379c76.tar.gz
Fix leaks in label strings allocation in COPs
p4raw-id: //depot/perl@29601
Diffstat (limited to 'cop.h')
-rw-r--r--cop.h12
1 files changed, 5 insertions, 7 deletions
diff --git a/cop.h b/cop.h
index 91f8d45a10..e80f865af4 100644
--- a/cop.h
+++ b/cop.h
@@ -187,20 +187,17 @@ struct cop {
# define CopSTASH_set(c,hv) CopSTASHPV_set(c, (hv) ? HvNAME_get(hv) : NULL)
# define CopSTASH_eq(c,hv) ((hv) && stashpv_hvname_match(c,hv))
# define CopLABEL(c) ((c)->cop_label)
-/* Don't free the original label here, it will be freed by the parser */
-# ifdef NETWARE
-# define CopLABEL_set(c,pv) (CopLABEL(c) = ((pv) ? savepv(pv) : NULL))
-# else
-# define CopLABEL_set(c,pv) (CopLABEL(c) = savesharedpv(pv))
-# endif
+# define CopLABEL_set(c,pv) (CopLABEL(c) = (pv))
# ifdef NETWARE
# define CopSTASH_free(c) SAVECOPSTASH_FREE(c)
# define CopFILE_free(c) SAVECOPFILE_FREE(c)
# define CopLABEL_free(c) SAVECOPLABEL_FREE(c)
+# define CopLABEL_alloc(pv) ((pv)?savepv(pv):NULL)
# else
# define CopSTASH_free(c) PerlMemShared_free(CopSTASHPV(c))
# define CopFILE_free(c) (PerlMemShared_free(CopFILE(c)),(CopFILE(c) = NULL))
# define CopLABEL_free(c) (PerlMemShared_free(CopLABEL(c)),(CopLABEL(c) = NULL))
+# define CopLABEL_alloc(pv) ((pv)?savesharedpv(pv):NULL)
# endif
#else
# define CopFILEGV(c) ((c)->cop_filegv)
@@ -221,10 +218,11 @@ struct cop {
/* cop_stash is not refcounted */
# define CopSTASHPV_set(c,pv) CopSTASH_set((c), gv_stashpv(pv,GV_ADD))
# define CopSTASH_eq(c,hv) (CopSTASH(c) == (hv))
+# define CopLABEL_alloc(pv) ((pv)?savepv(pv):NULL)
# define CopLABEL_set(c,pv) (CopLABEL(c) = (pv))
# define CopSTASH_free(c)
# define CopFILE_free(c) (SvREFCNT_dec(CopFILEGV(c)),(CopFILEGV(c) = NULL))
-# define CopLABEL_free(c)
+# define CopLABEL_free(c) (Safefree(CopLABEL(c)),(CopLABEL(c) = NULL))
#endif /* USE_ITHREADS */