# New Ticket Created by  Ron Blaschke 
# Please include the string:  [perl #43529]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=43529 >


Adds some range check assertions to F<compilers/imcc/sets.c>.  Please
double check if I got them right!

Assuming the assertions are good there seems to be a problem with its
use, at least for Parrot r19565, Win32, VC++ 8.0.  I don't think it's
platform dependent, though.


    ...
    .\parrot.exe -o runtime\parrot\library\String\Utils.pbc
runtime\parrot\library\String\Utils.pir
    .\parrot.exe -o runtime\parrot\library\YAML\Parser\Syck.pbc
runtime\parrot\library\YAML\Parser\Syck.pir
    .\parrot.exe -o runtime\parrot\library\STM.pbc
runtime\parrot\library\STM.pir
Assertion failed: element >= 0 && element < s->length, file
compilers\imcc\sets.c, line 108


Changed Files:
    compilers/imcc/sets.c

Ron
Index: compilers/imcc/sets.c
===================================================================
--- compilers/imcc/sets.c       (revision 19565)
+++ compilers/imcc/sets.c       (working copy)
@@ -86,6 +86,7 @@
 void
 set_add(Set *s /*NN*/, int element)
 {
+    assert(element >= 0 && element < s->length);
     s->bmp[element >> 3] |= (1 << (element & 7));
 }
 
@@ -104,6 +105,7 @@
 set_contains(const Set *s /*NN*/, int element)
     /* WARN_UNUSED */
 {
+    assert(element >= 0 && element < s->length);
 #ifdef __LCC__
     /* workaround for another lcc bug.. */
     const int tmp = (1 << (element & 7));

Reply via email to