In a couple of places we store strdup-ed C-strings in our python objects, free
these when the python objects get destroyed.
---
src/pydevice.c | 3 +++
src/pydisk.c | 1 +
src/pyfilesys.c | 1 +
src/pytimer.c | 20 ++++++++++++++++++++
4 files changed, 25 insertions(+), 0 deletions(-)
+ /* self->state_name now points to the internal buffer of a PyString object,
+ which may be freed when its refcount drops to zero, so strdup it. */
+ if (self->state_name) {
+ self->state_name = strdup(self->state_name);
+ if (!self->state_name) {
+ PyErr_NoMemory();
+ return -3;
+ }
+ }
+
return 0;
}
if (PyErr_Occurred()) {
return -1;
}
+ /* self->state_name now points to the internal buffer of a PyString obj
+ which may be freed when its refcount drops to zero, so strdup it. */
+ if (self->state_name) {
+ self->state_name = strdup(self->state_name);
+ if (!self->state_name) {
+ PyErr_NoMemory();
+ return -2;
+ }
+ }
} else {
PyErr_Format(PyExc_AttributeError, "_ped.Timer object has no
attribute %s", member);
return -1;
--
1.6.1.3
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
02-20-2009, 02:47 PM
Chris Lumens
PATCH: pyparted: Free c-strings on dealloc too
> In a couple of places we store strdup-ed C-strings in our python objects, free
> these when the python objects get destroyed.
> ---
> src/pydevice.c | 3 +++
> src/pydisk.c | 1 +
> src/pyfilesys.c | 1 +
> src/pytimer.c | 20 ++++++++++++++++++++
> 4 files changed, 25 insertions(+), 0 deletions(-)
This looks fine, though I'd still rather kill pytimer.c than do anything
to it. We've been waffling on keeping it or not, and I'm strongly on
the side of not. I'll apply, push, etc. Thanks for the patch.
- Chris
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list