Skip to content

Commit a5dfe1b

Browse files
Update src/PyListProxyHandler.cc
Co-authored-by: Caleb Aikens <[email protected]>
1 parent 525f530 commit a5dfe1b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/PyListProxyHandler.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,12 @@ static bool array_unshift(JSContext *cx, unsigned argc, JS::Value *vp) { // sure
164164
JS::RootedValue elementVal(cx);
165165
for (int index = args.length() - 1; index >= 0; index--) {
166166
elementVal.set(args[index].get());
167-
if (PyList_Insert(self, 0, pyTypeFactory(cx, elementVal)) < 0) {
167+
PyObject *value = pyTypeFactory(cx, elementVal);
168+
if (PyList_Insert(self, 0, value) < 0) {
169+
Py_DECREF(value);
168170
return false;
169171
}
172+
Py_DECREF(value);
170173
}
171174

172175
args.rval().setInt32(PyList_GET_SIZE(self));

0 commit comments

Comments
 (0)