diff options
author | Father Chrysostomos <sprout@cpan.org> | 2016-09-06 22:11:05 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2016-09-06 22:14:59 -0700 |
commit | 6b4217073fa5e351c7c41aa008f521a158e84237 (patch) | |
tree | 3c20b0a7696de02adbf011da857fe3327a5ebd84 /perl.h | |
parent | 10068948b21836d5094958b8b2766eb9393c909b (diff) | |
download | perl-6b4217073fa5e351c7c41aa008f521a158e84237.tar.gz |
[perl #129106] Check for null PL_curcop in IN_LC()
or, rather, in macros that it calls.
When exiting a string eval, the current cop may be freed, so PL_curcop
gets set to null. With the -DC option, we may end up printfing NVs
during scope exit, so the locale macros used to make sure that the
locale is sane before converting the numbers to strings need to make
sure not to read PL_curcop->cop_hints when PL_curcop is null.
This used to crash with: ./miniperl -DC -e'eval "l/A"'
I’m not sure how to write a test for this, or even whether it’s worth
writing a test for -D, which often changes behaviour depending on
porters’ whims.
Diffstat (limited to 'perl.h')
-rw-r--r-- | perl.h | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -6002,7 +6002,8 @@ typedef struct am_table_short AMTS; /* Returns TRUE if the plain locale pragma without a parameter is in effect */ -# define IN_LOCALE_RUNTIME cBOOL(CopHINTS_get(PL_curcop) & HINT_LOCALE) +# define IN_LOCALE_RUNTIME (PL_curcop \ + && CopHINTS_get(PL_curcop) & HINT_LOCALE) /* Returns TRUE if either form of the locale pragma is in effect */ # define IN_SOME_LOCALE_FORM_RUNTIME \ @@ -6023,7 +6024,7 @@ typedef struct am_table_short AMTS; # define IN_LC_PARTIAL_COMPILETIME cBOOL(PL_hints & HINT_LOCALE_PARTIAL) # define IN_LC_PARTIAL_RUNTIME \ - cBOOL(CopHINTS_get(PL_curcop) & HINT_LOCALE_PARTIAL) + (PL_curcop && CopHINTS_get(PL_curcop) & HINT_LOCALE_PARTIAL) # define IN_LC_COMPILETIME(category) \ (IN_LC_ALL_COMPILETIME || (IN_LC_PARTIAL_COMPILETIME \ |