Something in BitArray corrupts heap-memory?


#1

Hi, i’m not 100% sure, but something was corrupting the heap memory while using some encryption functions.
Now i found something.

juce_BitArray.cpp was changed with revision 384.
With the old version i have no problems so far.

163c163
< return (bit >= 0 && bit <= highestBit)

return (((unsigned int) bit) <= (unsigned int) highestBit)

214c214
< if (bit >= 0 && bit <= highestBit)

if (((unsigned int) bit) <= (unsigned int) highestBit)

926c926
< if (digit >= 0 && digit < base)

        if (((unsigned int) digit) < (unsigned int) base)

#2

Those changes just apply a very simple (but quite cunning) optimisation - it shouldn’t make any difference to how it works. I doubt if BitArray is your culprit.


#3

…agh, no, I just thought twice about that, and of course it’s a problem, because highestBit can be negative. Doh! I’ve checked-in another version of that file now. Sorry!


#4

Thanks, good to know you found something.
It was really hard to evaluate what was corrupting the memory


#5

Yeah, sorry - that was a really dumb mistake. That’s the perils of using the code at the tip of SVN!


#6