On Sun, 2004-12-12 at 18:26, Bill Kendrick wrote:

> So okay, I'm seriously confused.  How did moving i-- cause an array overrun?
> 
> 
> This code is crashing for me:
> 
>   while (i--)
>     {
>       mc = work + i;

If you have N items and need 0-based access to them,
the "while(N--)" loop is a nice idiom for handling
the problem.

When you moved the i-- past the assignment of mc, the
values assigned to mc become 1-based instead of 0-based.

Add -lefence to your compiler flags to link in Electric
Fence if you want to reliably see the problem.

Valgrind would be even better.



_______________________________________________
Tuxpaint-dev mailing list
[EMAIL PROTECTED]
http://tux4kids.net/mailman/listinfo/tuxpaint-dev

Reply via email to