changeset 1458:5f8025eb7c0c

cdefer: Fixed untimely deallocation.
author Marcel Keller <mkeller@cs.au.dk>
date Mon, 26 Jul 2010 21:05:15 +0200
parents 94fe7180f9bf
children 18429fdf5339
files viff/cdefer.c
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/viff/cdefer.c	Wed Jul 21 15:33:28 2010 +0200
+++ b/viff/cdefer.c	Mon Jul 26 21:05:15 2010 +0200
@@ -673,6 +673,9 @@
                     return NULL;
                 }
 
+		// self->result might be replaced and thus decref'd
+		// while running its callback.
+		Py_INCREF(self->result);
                 result = cdefer_Deferred__addCallbacks(
                     (cdefer_Deferred *)self->result, _continue,
                     _continue, Py_None, Py_None, Py_None, Py_None);
@@ -680,6 +683,7 @@
                  * (when errored) in addCallbacks, either way, we own
                  * one too, and don't need it anymore. */
                 Py_DECREF(_continue);
+		Py_DECREF(self->result);
 
                 if (!result) {
                     return NULL;