summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2006-04-12 22:45:12 +0000
committerNicholas Clark <nick@ccl4.org>2006-04-12 22:45:12 +0000
commit72dc9ed5af65c946f73050becea29207a1af86c1 (patch)
tree77d02ca4340063d7184142085f9527f83a40992e /util.c
parentaa283a383ef6540d57dd786b93d8ba9bd303e3e6 (diff)
downloadperl-72dc9ed5af65c946f73050becea29207a1af86c1.tar.gz
Change cop_warnings from an SV holding the warnings bitmask to a
directly (shared) malloc()ed buffer holding the warnings bitmask. This avoids bugs/crashes when the interpreter that created an optree is freed but the optree remains in use by other interpreters. p4raw-id: //depot/perl@27779
Diffstat (limited to 'util.c')
-rw-r--r--util.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/util.c b/util.c
index b4ed7f27ad..abd0db9c80 100644
--- a/util.c
+++ b/util.c
@@ -1531,7 +1531,18 @@ Perl_ckwarn_d(pTHX_ U32 w)
;
}
-
+/* Set buffer=NULL to get a new one. */
+STRLEN *
+Perl_new_warnings_bitfield(STRLEN *buffer, const char *const bits,
+ STRLEN size) {
+ const MEM_SIZE len_wanted = sizeof(STRLEN) + size;
+
+ buffer = specialWARN(buffer) ? PerlMemShared_malloc(len_wanted)
+ : PerlMemShared_realloc(buffer, len_wanted);
+ buffer[0] = size;
+ Copy(bits, (buffer + 1), size, char);
+ return buffer;
+}
/* since we've already done strlen() for both nam and val
* we can use that info to make things faster than