This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Strengthen the ix zero min-clamping to panic.
authorJarkko Hietaniemi <jhi@iki.fi>
Thu, 29 May 2014 15:09:48 +0000 (11:09 -0400)
committerJarkko Hietaniemi <jhi@iki.fi>
Thu, 29 May 2014 15:15:57 +0000 (11:15 -0400)
Currently the ix cannot ever be less than zero (detected by Coverity).
Furthermore, it probably should never get less than zero, so panic if
that ever happens.

[perl #121897]

Fix for Coverity perl5 CID 28946:
at_least: At condition ix < 0, the value of ix must be at least 0.
dead_error_condition: The condition ix < 0 cannot be true.
Logically dead code (DEADCODE)
dead_error_line: Execution cannot reach this statement ix = 0;

pp_ctl.c

index a5c29a0..bbd7149 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -3098,7 +3098,7 @@ PP(pp_goto) /* also pp_dump */
            I32 oldsave;
 
            if (ix < 0)
            I32 oldsave;
 
            if (ix < 0)
-               ix = 0;
+               DIE(aTHX_ "panic: docatch: illegal ix=%ld", (long)ix);
            dounwind(ix);
            TOPBLOCK(cx);
            oldsave = PL_scopestack[PL_scopestack_ix];
            dounwind(ix);
            TOPBLOCK(cx);
            oldsave = PL_scopestack[PL_scopestack_ix];