summaryrefslogtreecommitdiff
path: root/pp_pack.c
diff options
context:
space:
mode:
authorHugo van der Sanden <hv@crypt.org>2015-02-18 14:59:53 +0000
committerHugo van der Sanden <hv@crypt.org>2015-02-18 16:06:58 +0000
commitfc1bb3f2dcaaac9f305b27acb4800babdc8a06f3 (patch)
tree816deaca5b07a9b4e59bc1b8066a321abb5e7ef0 /pp_pack.c
parentd0bec20370cb0ec3e757fde65d8f1d13693e913f (diff)
downloadperl-fc1bb3f2dcaaac9f305b27acb4800babdc8a06f3.tar.gz
[perl #123874] fix argument underflow for pack()
NEXTFROM() modified the item count while testing it, so the next use saw the count (of -1) as non-zero and ended up trying to write ~1 bytes.
Diffstat (limited to 'pp_pack.c')
-rw-r--r--pp_pack.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/pp_pack.c b/pp_pack.c
index e86de04bbb..0cbe3c4d4b 100644
--- a/pp_pack.c
+++ b/pp_pack.c
@@ -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) {