# New Ticket Created by Paul Cochrane
# Please include the string: [perl #46227]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=46227 >
This patch is brought to you by the RT command line utility because
parrotbug doesn't seem to think I'm the 'Hi' virus...
In compilers/imcc/optimizer.c there is the possiblity that a negative
number will be used as an index to an array; see Coverity CID 20. This
patch removes this issue. If noone complains, I'll apply the patch in
about 3 days; if it is approved, then I'll apply it at the first
opportunity.
Paul
Index: compilers/imcc/optimizer.c
===================================================================
--- compilers/imcc/optimizer.c (revision 21951)
+++ compilers/imcc/optimizer.c (working copy)
@@ -934,11 +934,16 @@
(next->type & IF_goto) &&
!strcmp(next->op, "branch") &&
strcmp(next->r[0]->name, get_branch_reg(ins)->name)) {
+ const int regno = get_branch_regno(ins);
IMCC_debug(interp, DEBUG_OPT1,
"found branch to branch '%s' %I\n",
r->first_ins->r[0]->name, next);
unit->ostat.branch_branch++;
- ins->r[get_branch_regno(ins)] = next->r[0];
+ if (regno < 0) {
+ real_exception(interp, NULL, 1,
+ "Register number determination failed in
branch_branch()");
+ }
+ ins->r[regno] = next->r[0];
changed = 1;
}
}