summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2013-06-21 14:19:54 -0700
committerFather Chrysostomos <sprout@cpan.org>2013-06-22 23:16:40 -0700
commit66379c06cdfaf5fb5c63d8518f0a1e65d80b1072 (patch)
tree51a467ec3a39a00bb8094a8d562897cd74cee1fd /util.c
parent310f4fdb24138eb4c2139770a79916c15593c66d (diff)
downloadperl-66379c06cdfaf5fb5c63d8518f0a1e65d80b1072.tar.gz
util.c: Stop ck_index/fbm_compile from abusing readonliness
There is currently a convenient exception in sv_force_normal that allows read-only scalars to be modified at compile time. I want to get rid of it, since most code that relies on it is buggy. So stop ck_index from relying on that when it calls fbm_compile by stopping fbm_compile from triggering the error by forcing stringifica- tion of variables that are already strings.
Diffstat (limited to 'util.c')
-rw-r--r--util.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/util.c b/util.c
index e07ae4d203..11a7863d3b 100644
--- a/util.c
+++ b/util.c
@@ -539,7 +539,9 @@ Perl_fbm_compile(pTHX_ SV *sv, U32 flags)
if (mg && mg->mg_len >= 0)
mg->mg_len++;
}
- s = (U8*)SvPV_force_mutable(sv, len);
+ if (!SvPOK(sv) || SvNIOKp(sv) || SvIsCOW(sv))
+ s = (U8*)SvPV_force_mutable(sv, len);
+ else s = (U8 *)SvPV_mutable(sv, len);
if (len == 0) /* TAIL might be on a zero-length string. */
return;
SvUPGRADE(sv, SVt_PVMG);