PatchSet 5970 
Date: 2005/02/04 14:43:21
Author: robilad
Branch: HEAD
Tag: (none) 
Log:
Fix for array index checking in interpreter

2005-02-04  Dalibor Topic  <[EMAIL PROTECTED]>

        * kaffe/kaffevm/intrp/icode.h (check_array_index):
        Turned into a proper static inline funtion. Cleaned up
        and documented. Made it throw an ArrayIndexOutOfBounds
        exception for negative index values. That fixes a
        problem detected by OfBiz 3 on powerpc-linux-intrp.

Members: 
        ChangeLog:1.3509->1.3510 
        kaffe/kaffevm/intrp/icode.h:1.21->1.22 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3509 kaffe/ChangeLog:1.3510
--- kaffe/ChangeLog:1.3509      Fri Feb  4 10:36:11 2005
+++ kaffe/ChangeLog     Fri Feb  4 14:43:21 2005
@@ -1,5 +1,13 @@
 2005-02-04  Dalibor Topic  <[EMAIL PROTECTED]>
 
+       * kaffe/kaffevm/intrp/icode.h (check_array_index):
+       Turned into a proper static inline funtion. Cleaned up
+       and documented. Made it throw an ArrayIndexOutOfBounds
+       exception for negative index values. That fixes a 
+       problem detected by OfBiz 3 on powerpc-linux-intrp.
+
+2005-02-04  Dalibor Topic  <[EMAIL PROTECTED]>
+
        * kaffe/kaffevm/classMethod.c (retry):
        Removed unused variables.
 
Index: kaffe/kaffe/kaffevm/intrp/icode.h
diff -u kaffe/kaffe/kaffevm/intrp/icode.h:1.21 
kaffe/kaffe/kaffevm/intrp/icode.h:1.22
--- kaffe/kaffe/kaffevm/intrp/icode.h:1.21      Thu Aug 19 19:29:03 2004
+++ kaffe/kaffe/kaffevm/intrp/icode.h   Fri Feb  4 14:43:23 2005
@@ -12,6 +12,9 @@
 #ifndef __icode_h
 #define        __icode_h
 
+#include "slots.h"
+#include "soft.h"
+
 #define        move_long_const(t, c)                   (t)[0].v.tlong = (c)
 #define        add_long(t, f1, f2)                     (t)[0].v.tlong = 
(f1)[0].v.tlong + (f2)[0].v.tlong
 #define        sub_long(t, f1, f2)                     (t)[0].v.tlong = 
(f1)[0].v.tlong - (f2)[0].v.tlong
@@ -305,9 +308,25 @@
 
 #define        adjustpc(a)                             /* Not needed for 
interpreter */
 
-#define        check_array_index(O, I)                 if ((I)[0].v.tint >= 
ARRAY_SIZE((O)[0].v.taddr)) { \
-                                                       soft_badarrayindex(); \
-                                               }
+/* check if an array index is out of bounds.
+ *
+ * it is out of bounds if the index is less then zero
+ * or if it is larger or equal to the size of the array
+ * to be indexed.
+ */ 
+static inline void check_array_index(const slots* array_slot, 
+                                    const slots* index_slot)
+{
+       const jint array_index = index_slot->v.tint;
+       const void* array_reference = array_slot->v.taddr;
+
+       if (array_index < 0 ||
+           array_index >= ARRAY_SIZE(array_reference))
+       {
+               soft_badarrayindex();
+       }
+}
+
 #define        build_call_frame(SIG, OBJ, NRARGS)      /* Not needed for 
interpreter */
 
 

_______________________________________________
kaffe mailing list
[email protected]
http://kaffe.org/cgi-bin/mailman/listinfo/kaffe

Reply via email to