Skip to content

Commit 3a65dc1

Browse files
unknownunknown
unknown
authored and
unknown
committed
Make sure temporary dictionary is disposed correctly.
1 parent 150a900 commit 3a65dc1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/runtime/metatype.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,10 @@ public static IntPtr tp_new(IntPtr tp, IntPtr args, IntPtr kw) {
9494
// into python.
9595
if (IntPtr.Zero != dict) {
9696
Runtime.Incref(dict);
97-
PyDict clsDict = new PyDict(dict);
98-
if (clsDict.HasKey("__assembly__") || clsDict.HasKey("__namespace__"))
99-
return TypeManager.CreateSubType(name, base_type, dict);
97+
using (PyDict clsDict = new PyDict(dict)) {
98+
if (clsDict.HasKey("__assembly__") || clsDict.HasKey("__namespace__"))
99+
return TypeManager.CreateSubType(name, base_type, dict);
100+
}
100101
}
101102

102103
// otherwise just create a basic type without reflecting back into the managed side.

0 commit comments

Comments
 (0)