Skip to content

Commit f368890

Browse files
committed
Fix C-API calls
1 parent 04563f0 commit f368890

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

Modules/_remote_debugging/code_objects.c

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,35 @@ make_location_info(RemoteUnwinderObject *unwinder, int lineno, int end_lineno,
221221
set_exception_cause(unwinder, PyExc_MemoryError, "Failed to create LocationInfo");
222222
return NULL;
223223
}
224-
PyStructSequence_SetItem(info, 0, PyLong_FromLong(lineno));
225-
PyStructSequence_SetItem(info, 1, PyLong_FromLong(end_lineno));
226-
PyStructSequence_SetItem(info, 2, PyLong_FromLong(col_offset));
227-
PyStructSequence_SetItem(info, 3, PyLong_FromLong(end_col_offset));
224+
225+
PyObject *py_lineno = PyLong_FromLong(lineno);
226+
if (py_lineno == NULL) {
227+
Py_DECREF(info);
228+
return NULL;
229+
}
230+
PyStructSequence_SetItem(info, 0, py_lineno); // steals reference
231+
232+
PyObject *py_end_lineno = PyLong_FromLong(end_lineno);
233+
if (py_end_lineno == NULL) {
234+
Py_DECREF(info);
235+
return NULL;
236+
}
237+
PyStructSequence_SetItem(info, 1, py_end_lineno); // steals reference
238+
239+
PyObject *py_col_offset = PyLong_FromLong(col_offset);
240+
if (py_col_offset == NULL) {
241+
Py_DECREF(info);
242+
return NULL;
243+
}
244+
PyStructSequence_SetItem(info, 2, py_col_offset); // steals reference
245+
246+
PyObject *py_end_col_offset = PyLong_FromLong(end_col_offset);
247+
if (py_end_col_offset == NULL) {
248+
Py_DECREF(info);
249+
return NULL;
250+
}
251+
PyStructSequence_SetItem(info, 3, py_end_col_offset); // steals reference
252+
228253
return info;
229254
}
230255

0 commit comments

Comments
 (0)