Things you shouldn't do

Paul McGuire ptmcg at austin.rr.com
Wed Mar 30 09:12:51 EST 2005


Here's another real world example, although it was in C:

char* ptr;
assert( ptr = malloc( memsize ); )

Of course, this worked when built in debug, but it took a while to
track down why it wasn't working in the release build (the assert()'s
were stripped out in the release builds, so ptr didn't allocate any
memory).  Unfortunately, the runtime failure happened in an entirely
different part of the code, since ptr wasn't initialized to null, so
this particular routine just merrily stomped on whatever memory address
happened to initialize in ptr.

-- Paul




More information about the Python-list mailing list