Patch: fix for infinite loop in gcjh
Tom Tromey
tromey@cygnus.com
Wed Apr 19 09:04:00 GMT 2000
Bryce pointed out to me that my recent gcjh patch introduced a
potential infinite loop. This patch fixes it. I'm checking it in.
2000-04-19 Tom Tromey <tromey@cygnus.com>
* gjavah.c (cxx_keyword_subst): Avoid potential infinite loop.
Tom
Index: gjavah.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/gjavah.c,v
retrieving revision 1.54
diff -u -r1.54 gjavah.c
--- gjavah.c 2000/04/18 16:13:16 1.54
+++ gjavah.c 2000/04/19 15:19:54
@@ -407,12 +407,15 @@
{
int last = sizeof (cxx_keywords) / sizeof (const char *);
int first = 0;
- int mid, r;
+ int mid = (last + first) / 2;
+ int old = -1;
- while (last != first)
+ for (mid = (last + first) / 2;
+ mid != old;
+ old = mid, mid = (last + first) / 2)
{
- mid = (last + first) / 2;
- r = utf8_cmp (str, length, cxx_keywords[mid]);
+ int r = utf8_cmp (str, length, cxx_keywords[mid]);
+
if (r == 0)
{
char *str = xmalloc (9 + strlen (cxx_keywords[mid]));
More information about the Gcc-patches
mailing list