add assertion to prevent stack corruption in XSUB
authorDoug Bell <madcityzen@gmail.com>
Wed, 3 Jun 2015 03:34:42 +0000 (22:34 -0500)
committerDavid Mitchell <davem@iabyn.com>
Fri, 2 Oct 2015 10:29:35 +0000 (11:29 +0100)
We should not be able to return negative offsets from the stack in
XSUBs.

XSUB.h

diff --git a/XSUB.h b/XSUB.h
index 4548fc9..e64bc83 100644 (file)
--- a/XSUB.h
+++ b/XSUB.h
@@ -327,6 +327,7 @@ Rethrows a previously caught exception.  See L<perlguts/"Exception Handling">.
 #define XSRETURN(off)                                  \
     STMT_START {                                       \
        const IV tmpXSoff = (off);                      \
+       assert(tmpXSoff >= 0);\
        PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1);      \
        return;                                         \
     } STMT_END