Core dump revisited
Duncan Booth
duncan.booth at invalid.invalid
Tue Dec 19 11:11:36 EST 2006
More information about the Python-list mailing list
Tue Dec 19 11:11:36 EST 2006
- Previous message (by thread): Core dump revisited
- Next message (by thread): Core dump revisited
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Sheldon" <shejo284 at gmail.com> wrote: > I am new to this and copied this code from a colleague. So, it > corrupts the pointer. How do I do this properly? > Here is at least part of your problem: msgop = PyList_GetItem(work.msgobj, i); work.msg_scenes[i] = PyString_AsString(msgop); ppsop = PyList_GetItem(work.ppsobj, i); work.pps_scenes[i] = PyString_AsString(ppsop); ... free(work.pps_scenes[i]); free(work.msg_scenes[i]); You initialised msg_scenes and pps_scenes with a malloc'ed block but you then just overwrote the pointer with the result of PyString_AsString. You don't own the memory for the string returned from PyString_AsString, so freeing it will cause a corruption. You should copy the string data into the malloc'ed block (with appropriate length checks).
- Previous message (by thread): Core dump revisited
- Next message (by thread): Core dump revisited
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list