Skip to content

Commit 21722f8

Browse files
committed
gv_magicalize: Length 0 input=>Immediately return false
If you trace the execution of what happens to 0 length input, it relies on a NUL terminator in the string, and does nothing. Simply return false immediately instead.
1 parent 1f22b8d commit 21722f8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

gv.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2086,11 +2086,14 @@ S_gv_magicalize(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len,
20862086

20872087
PERL_ARGS_ASSERT_GV_MAGICALIZE;
20882088

2089+
if (len == 0) {
2090+
return false;
2091+
}
2092+
20892093
if (stash != PL_defstash) { /* not the main stash */
20902094
/* We only have to check for a few names here: a, b, EXPORT, ISA
20912095
and VERSION. All the others apply only to the main stash or to
20922096
CORE (which is checked right after this). */
2093-
if (len) {
20942097
switch (*name) {
20952098
case 'E':
20962099
if (
@@ -2124,7 +2127,6 @@ S_gv_magicalize(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len,
21242127
goto try_core;
21252128
}
21262129
goto ret;
2127-
}
21282130
try_core:
21292131
if (len > 1 /* shortest is uc */ && HvNAMELEN_get(stash) == 4) {
21302132
/* Avoid null warning: */

0 commit comments

Comments
 (0)