@@ -243,6 +243,7 @@ Tracer_record_pair(Tracer *self, int l1, int l2)
243
243
static int
244
244
Tracer_trace (Tracer * self , PyFrameObject * frame , int what , PyObject * arg )
245
245
{
246
+ int ret = 0 ;
246
247
PyObject * filename = NULL ;
247
248
PyObject * tracename = NULL ;
248
249
@@ -326,7 +327,10 @@ Tracer_trace(Tracer *self, PyFrameObject *frame, int what, PyObject *arg)
326
327
STATS ( self -> stats .errors ++ ; )
327
328
return -1 ;
328
329
}
329
- PyDict_SetItem (self -> should_trace_cache , filename , tracename );
330
+ if (PyDict_SetItem (self -> should_trace_cache , filename , tracename ) < 0 ) {
331
+ STATS ( self -> stats .errors ++ ; )
332
+ return -1 ;
333
+ }
330
334
}
331
335
else {
332
336
Py_INCREF (tracename );
@@ -341,8 +345,12 @@ Tracer_trace(Tracer *self, PyFrameObject *frame, int what, PyObject *arg)
341
345
STATS ( self -> stats .errors ++ ; )
342
346
return -1 ;
343
347
}
344
- PyDict_SetItem (self -> data , tracename , file_data );
348
+ ret = PyDict_SetItem (self -> data , tracename , file_data );
345
349
Py_DECREF (file_data );
350
+ if (ret < 0 ) {
351
+ STATS ( self -> stats .errors ++ ; )
352
+ return -1 ;
353
+ }
346
354
}
347
355
self -> cur_file_data = file_data ;
348
356
SHOWLOG (self -> depth , frame -> f_lineno , filename , "traced" );
@@ -389,8 +397,16 @@ Tracer_trace(Tracer *self, PyFrameObject *frame, int what, PyObject *arg)
389
397
else {
390
398
/* Tracing lines: key is simply this_line. */
391
399
PyObject * this_line = MyInt_FromLong (frame -> f_lineno );
392
- PyDict_SetItem (self -> cur_file_data , this_line , Py_None );
400
+ if (this_line == NULL ) {
401
+ STATS ( self -> stats .errors ++ ; )
402
+ return -1 ;
403
+ }
404
+ ret = PyDict_SetItem (self -> cur_file_data , this_line , Py_None );
393
405
Py_DECREF (this_line );
406
+ if (ret < 0 ) {
407
+ STATS ( self -> stats .errors ++ ; )
408
+ return -1 ;
409
+ }
394
410
}
395
411
}
396
412
self -> last_line = frame -> f_lineno ;
0 commit comments