This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[gcjx] Patch: FYI: check method argument size
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 16 Jan 2005 17:00:04 -0700
- Subject: [gcjx] Patch: FYI: check method argument size
- Reply-to: tromey at redhat dot com
I'm checking this in on the gcjx branch.
This fixes a jacks failure by adding a check for the number of words
taken by a method's arguments.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* bytecode/classwriter.cc (write): Check number of words required
by arguments.
Index: bytecode/classwriter.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/bytecode/Attic/classwriter.cc,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 classwriter.cc
--- bytecode/classwriter.cc 13 Jan 2005 03:18:34 -0000 1.1.2.1
+++ bytecode/classwriter.cc 17 Jan 2005 00:02:31 -0000
@@ -1,6 +1,6 @@
// Write a class file.
-// Copyright (C) 2004 Free Software Foundation, Inc.
+// Copyright (C) 2004, 2005 Free Software Foundation, Inc.
//
// This file is part of GCC.
//
@@ -26,6 +26,7 @@
#include "bytecode/block.hh"
#include "bytecode/attribute.hh"
#include "bytecode/generate.hh"
+#include "bytecode/byteutil.hh"
#include <fcntl.h>
@@ -229,6 +230,18 @@
{
bytecode_attribute_list *attrs = new bytecode_attribute_list ();
+ // One last check on the method.
+ std::list<ref_variable_decl> params = (*i)->get_parameters ();
+ int len = 0;
+ if (! (*i)->static_p ())
+ ++len;
+ for (std::list<ref_variable_decl>::const_iterator j = params.begin ();
+ j != params.end ();
+ ++j)
+ len += wide_p ((*j)->type ()) ? 2 : 1;
+ if (len > 255)
+ throw (*i)->error ("method requires more than 255 words of arguments");
+
pool->add_utf ((*i)->get_name ());
pool->add_utf ((*i)->get_descriptor ());
if (! (*i)->abstract_p () && ! (*i)->native_p ())