Message78454
> Whenever the documentation says "you must not" it really says "don't do
> that or your application *will* crash, burn and die"... Of course I can
> allocate storage for the string, copy it's content and then free or -
> nothing will happen. How would it cause a crash - it's my own pointer.
Suppose you do
char *s = malloc(MAXPATH);
if (!PyArg_ParseTuple("s", &s))return NULL;
do_something_with(s);
free(s);
then your application *will* crash, burn, and die - because s gets
changed in the call; the original malloc result is garbage, and the
free call will likely crash the malloc implementation (as the block
it points to wasn't malloc-allocated, and isn't the beginning of a
block). |
|
Date |
User |
Action |
Args |
2008-12-29 13:31:41 | loewis | set | recipients:
+ loewis, georg.brandl, ggenellina, pitrou, ebfe |
2008-12-29 13:31:41 | loewis | link | issue4746 messages |
2008-12-29 13:31:40 | loewis | create | |
|