This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: FYI: verifier bug fix
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 28 Jan 2002 12:10:57 -0700
- Subject: Patch: FYI: verifier bug fix
- Reply-to: tromey at redhat dot com
I'm checking this in.
This fixes a verifier bug reported on the main list.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* verify.cc (class _Jv_BytecodeVerifier) [op_invokeinterface]:
`nargs' byte is number of words, not number of arguments.
Index: verify.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/verify.cc,v
retrieving revision 1.29
diff -u -r1.29 verify.cc
--- verify.cc 2002/01/28 00:46:23 1.29
+++ verify.cc 2002/01/28 18:23:55
@@ -2653,16 +2653,15 @@
opcode == op_invokeinterface,
&method_name,
&method_signature);
- int arg_count = _Jv_count_arguments (method_signature);
+ // NARGS is only used when we're processing
+ // invokeinterface. It is simplest for us to compute it
+ // here and then verify it later.
+ int nargs = 0;
if (opcode == op_invokeinterface)
{
- int nargs = get_byte ();
- if (nargs == 0)
- verify_fail ("too few arguments to invokeinterface");
+ nargs = get_byte ();
if (get_byte () != 0)
verify_fail ("invokeinterface dummy byte is wrong");
- if (nargs - 1 != arg_count)
- verify_fail ("wrong argument count for invokeinterface");
}
bool is_init = false;
@@ -2676,10 +2675,20 @@
verify_fail ("can't invoke method starting with `<'");
// Pop arguments and check types.
+ int arg_count = _Jv_count_arguments (method_signature);
type arg_types[arg_count];
compute_argument_types (method_signature, arg_types);
for (int i = arg_count - 1; i >= 0; --i)
- pop_type (arg_types[i]);
+ {
+ // This is only used for verifying the byte for
+ // invokeinterface.
+ nargs -= arg_types[i].depth ();
+ pop_type (arg_types[i]);
+ }
+
+ if (opcode == op_invokeinterface
+ && nargs != 1)
+ verify_fail ("wrong argument count for invokeinterface");
if (opcode != op_invokestatic)
{