Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed leaking reference

  • Loading branch information...
commit ec94c93f95ff25cdb7ef8396fdbb00c50806ea32 1 parent 3245c54
Kevin Manley authored
Showing with 3 additions and 1 deletion.
  1. +3 −1 python/objToJSON.c
View
4 python/objToJSON.c
@@ -582,9 +582,11 @@ void Object_beginTypeContext (PyObject **obj, JSONTypeContext *tc)
return;
}
- // NOTE: recursive call
+ // NOTE: recursive call to Object_beginTypeContext
+ Py_DECREF(*obj);
*obj = jsonDefaultResult;
Object_beginTypeContext(obj, tc);
+
return;
}

1 comment on commit ec94c93

@jskorpan

Hi,
Thanks for the pull request.

I think the Py_DECREF(*obj) line will cause us problems. As far as I see it we stand of at risk of actually deleting the object being encoded and possibly its entire sub structure.

Suppose the object we're decrefing is the root object which would have 1 or more references held to it. If the ref count is 1 and we decref it the refcount will hit 0 and the object and its sub objects will be deleted.

I played around with this myself using your old code and there's something fundamentally problematic with trying to retrofit this into the present encoder structures. Maybe we need some completely new thinking to make it work.

Please sign in to comment.
Something went wrong with that request. Please try again.