Skip to content

Commit dec7a74

Browse files
committed
Fix refcnt error
1 parent a8840b2 commit dec7a74

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/runtime/runtime_state.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ private static void RestoreObjects(IntPtr dummyGC)
146146
public static IEnumerable<IntPtr> PyGCGetObjects()
147147
{
148148
var gc = PyImport_ImportModule("gc");
149+
PythonException.ThrowIfIsNull(gc);
149150
var get_objects = PyObject_GetAttrString(gc, "get_objects");
150151
var objs = PyObject_CallObject(get_objects, IntPtr.Zero);
151152
var length = PyList_Size(objs);
@@ -168,6 +169,7 @@ public static IEnumerable<IntPtr> GetModuleNames()
168169
var name = PyList_GetItem(names, i);
169170
yield return name.DangerousGetAddress();
170171
}
172+
XDecref(names);
171173
}
172174

173175
private static void AddObjPtrToSet(IntPtr set, IntPtr obj)

0 commit comments

Comments
 (0)