summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pp.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/pp.c b/pp.c
index 863478d6c9..fe3c675f97 100644
--- a/pp.c
+++ b/pp.c
@@ -1521,8 +1521,10 @@ PP(pp_substr)
pos = POPi - arybase;
sv = POPs;
tmps = SvPV(sv, curlen);
- if (pos < 0)
+ if (pos < 0) {
pos += curlen + arybase;
+ if (pos < 0 && MAXARG < 3) pos = 0;
+ }
if (pos < 0 || pos > curlen) {
if (dowarn || lvalue)
warn("substr outside of string");