diff options
-rw-r--r-- | pp_pack.c | 2 | ||||
-rw-r--r-- | t/op/pack.t | 6 |
2 files changed, 6 insertions, 2 deletions
@@ -2094,7 +2094,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) char *cur = start + SvCUR(cat); bool needs_swap; -#define NEXTFROM (lengthcode ? lengthcode : items-- > 0 ? *beglist++ : &PL_sv_no) +#define NEXTFROM (lengthcode ? lengthcode : items > 0 ? (--items, *beglist++) : &PL_sv_no) #define PEEKFROM (lengthcode ? lengthcode : items > 0 ? *beglist : &PL_sv_no) switch (howlen) { diff --git a/t/op/pack.t b/t/op/pack.t index 8b464dd696..9416ad6e5e 100644 --- a/t/op/pack.t +++ b/t/op/pack.t @@ -12,7 +12,7 @@ my $no_endianness = $] > 5.009 ? '' : my $no_signedness = $] > 5.009 ? '' : "Signed/unsigned pack modifiers not available on this perl"; -plan tests => 14707; +plan tests => 14708; use strict; use warnings qw(FATAL all); @@ -2012,3 +2012,7 @@ package o { is pack("c", bless [], "o"), chr(42), 'overloading called'; is $o::str, undef, 'pack "c" does not call string overloading'; is $o::num, 1, 'pack "c" does call num overloading'; + +#[perl #123874]: argument underflow leads to corrupt length +eval q{ pack "pi/x" }; +ok(1, "argument underflow did not crash"); |