Skip to content

Commit 64e4a9d

Browse files
committed
Assert sanity of name+len arguments to allocmy()
Recent discussons on github [1] found a bug when calling this function as allocmy("", 0, 0) This ought not be allowed. The length must be at least 2, because the function checks the first two characters of `name`. [1]: #23574 (comment)
1 parent a7a8a28 commit 64e4a9d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

op.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,8 @@ Perl_allocmy(pTHX_ const char *const name, const STRLEN len, const U32 flags)
766766
const bool is_our = (PL_parser->in_my == KEY_our);
767767

768768
PERL_ARGS_ASSERT_ALLOCMY;
769+
assert(len >= 2);
770+
assert(name[0] && name[1]);
769771

770772
if (flags & ~SVf_UTF8)
771773
croak("panic: allocmy illegal flag bits 0x%" UVxf,

0 commit comments

Comments
 (0)