summaryrefslogtreecommitdiff
path: root/libjava/verify.cc
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2003-03-03 23:25:52 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2003-03-03 23:25:52 +0000
commit92691874d3d2e8d2540a7935051bdae2b32ba5a9 (patch)
treeab7b0c0f257f39479e009961f187e972c645f326 /libjava/verify.cc
parentdef13964951b3684cfc3ba5359058d23e37dd155 (diff)
downloadgcc-92691874d3d2e8d2540a7935051bdae2b32ba5a9.tar.gz
* verify.cc (handle_jsr_insn): Don't fail if `jsr' appears at end
of bytecode. (handle_ret_insn): Fail if returning to jsr that appears at end of bytecode. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@63744 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/verify.cc')
-rw-r--r--libjava/verify.cc25
1 files changed, 15 insertions, 10 deletions
diff --git a/libjava/verify.cc b/libjava/verify.cc
index dcb003dfb22..8f8c1df9eb1 100644
--- a/libjava/verify.cc
+++ b/libjava/verify.cc
@@ -1526,6 +1526,12 @@ private:
for (subr_info *subr = jsr_ptrs[csub]; subr != NULL; subr = subr->next)
{
+ // We might be returning to a `jsr' that is at the end of the
+ // bytecode. This is ok if we never return from the called
+ // subroutine, but if we see this here it is an error.
+ if (subr->pc >= current_method->code_length)
+ verify_fail ("fell off end");
+
// Temporarily modify the current state so it looks like we're
// in the enclosing context.
current_state->subroutine = get_subroutine (subr->pc);
@@ -1575,16 +1581,15 @@ private:
// the local variable state across the jsr, but the subroutine
// might change the stack depth, so we can't make any assumptions
// about it. So we have yet another special case. We know that
- // at this point PC points to the instruction after the jsr.
-
- // FIXME: what if we have a jsr at the end of the code, but that
- // jsr has no corresponding ret? Is this verifiable, or is it
- // not? If it is then we need a special case here.
- if (PC >= current_method->code_length)
- verify_fail ("fell off end");
-
- current_state->stacktop = state::NO_STACK;
- push_jump_merge (PC, current_state);
+ // at this point PC points to the instruction after the jsr. Note
+ // that it is ok to have a `jsr' at the end of the bytecode,
+ // provided that the called subroutine never returns. So, we have
+ // a special case here and another one when we handle the ret.
+ if (PC < current_method->code_length)
+ {
+ current_state->stacktop = state::NO_STACK;
+ push_jump_merge (PC, current_state);
+ }
invalidate_pc ();
}