parsers: use Py_INCREF safely
authorBryan O'Sullivan <bryano@fb.com>
Mon, 16 Sep 2013 12:12:37 -0700
changeset 19726 b3c8c6f2b5c1
parent 19725 5e25d71a58cc
child 19727 3d07b4a2f743
parsers: use Py_INCREF safely
mercurial/parsers.c
--- a/mercurial/parsers.c	Mon Sep 16 12:10:28 2013 -0700
+++ b/mercurial/parsers.c	Mon Sep 16 12:12:37 2013 -0700
@@ -540,11 +540,12 @@
 			      uncomp_len, base_rev, link_rev,
 			      parent_1, parent_2, c_node_id, 20);
 
-	if (entry)
+	if (entry) {
 		PyObject_GC_UnTrack(entry);
+		Py_INCREF(entry);
+	}
 
 	self->cache[pos] = entry;
-	Py_INCREF(entry);
 
 	return entry;
 }