libgst: 2013-06-26 Paolo Bonzini <bonz...@gnu.org> * libgst/dict.inl: In index_oop_spec and index_oop_put_spec, move index decrement after the scaling by sizeof(type) and the overflow test. This prepares for fixing the overflow test. --- libgst/ChangeLog | 6 ++++++ libgst/dict.inl | 20 ++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/libgst/ChangeLog b/libgst/ChangeLog index f5a77d7..893c380 100644 --- a/libgst/ChangeLog +++ b/libgst/ChangeLog @@ -1,3 +1,9 @@ +2013-06-26 Paolo Bonzini <bonz...@gnu.org> + + * libgst/dict.inl: In index_oop_spec and index_oop_put_spec, + move index decrement after the scaling by sizeof(type) and the + overflow test. This prepares for fixing the overflow test. + 2013-06-14 Gwenael Casaccio <gwenael.casac...@gmail.com> * libgst/dict.c: Remove useless code: gst_ordered_collection structure. diff --git a/libgst/dict.inl b/libgst/dict.inl index 434906a..3b029b0 100644 --- a/libgst/dict.inl +++ b/libgst/dict.inl @@ -985,8 +985,6 @@ index_oop_spec (OOP oop, if UNCOMMON (index < 1) return (NULL); - index--; - #define DO_INDEX_OOP(type, dest) \ /* Find the number of bytes in the object. */ \ maxByte = NUM_WORDS (object) * sizeof (PTR); \ @@ -998,9 +996,11 @@ index_oop_spec (OOP oop, + (instanceSpec >> ISP_NUMFIXEDFIELDS) * sizeof (PTR); \ \ /* Check that we're on bounds. */ \ - if UNCOMMON (index + sizeof(type) > maxByte) \ + if UNCOMMON (index > maxByte) \ return (NULL); \ \ + index -= sizeof(type); \ + \ /* Use a cast if unaligned accesses are supported, else memcpy. */ \ src = ((char *) object->data) + index; \ if (sizeof (type) <= sizeof (PTR)) \ @@ -1085,10 +1085,10 @@ index_oop_spec (OOP oop, case GST_ISP_POINTER: maxIndex = NUM_WORDS (object); index += instanceSpec >> ISP_NUMFIXEDFIELDS; - if UNCOMMON (index >= maxIndex) + if UNCOMMON (index > maxIndex) return (NULL); - return (object->data[index]); + return (object->data[index - 1]); } #undef DO_INDEX_OOP @@ -1117,8 +1117,6 @@ index_oop_put_spec (OOP oop, if UNCOMMON (index < 1) return (false); - index--; - #define DO_INDEX_OOP_PUT(type, cond, src) \ if COMMON (cond) \ { \ @@ -1132,9 +1130,11 @@ index_oop_put_spec (OOP oop, + (instanceSpec >> ISP_NUMFIXEDFIELDS) * sizeof (PTR); \ \ /* Check that we're on bounds. */ \ - if UNCOMMON (index + sizeof(type) > maxByte) \ + if UNCOMMON (index > maxByte) \ return (false); \ \ + index -= sizeof(type); \ + \ /* Use a cast if unaligned accesses are ok, else memcpy. */ \ if (sizeof (type) <= sizeof (PTR)) \ { \ @@ -1251,10 +1251,10 @@ index_oop_put_spec (OOP oop, case GST_ISP_POINTER: maxIndex = NUM_WORDS (object); index += instanceSpec >> ISP_NUMFIXEDFIELDS; - if UNCOMMON (index >= maxIndex) + if UNCOMMON (index > maxIndex) return (false); - object->data[index] = value; + object->data[index - 1] = value; return (true); } #undef DO_INDEX_OOP_PUT -- 1.8.2.1 _______________________________________________ help-smalltalk mailing list help-smalltalk@gnu.org https://lists.gnu.org/mailman/listinfo/help-smalltalk