Commits

Mark Shannon  committed 9d434d0 Draft

Fix leak in trace_recorder_register

  • Participants
  • Parent commits bd241de

Comments (0)

Files changed (2)

File Python/recording_interpreter.c

         assert(f->f_iblock == 0);
         f->f_stacktop = NULL;
         Py_DECREF(f);
-        optimiser->fail(optimiser, 0, "Exception raised");
+        optimiser->fail(optimiser, opcode, "Exception raised");
         return (HotPyReturnValue){ NULL, WHY_EXCEPTION};
     }
     if (why == WHY_YIELD)

File Python/trace_recorder_register.c

 static Py_ssize_t
 new_exit(HotPyTraceRecorder *opt, HotPyContext *context)
 {
+    int err;
     Py_ssize_t index;
     PyObject *exit;
     exit = HotPyExitObject_New(context);
     if (exit == NULL)
         FAILED(opt);
     index = PyList_Size(opt->exits);
-    if (PyList_Append(opt->exits, exit))
+    err = PyList_Append(opt->exits, exit);
+    Py_DECREF(exit);
+    if (err)
         FAILED(opt);
     return index;
 }
     Py_CLEAR(opt->exits);
     Py_CLEAR(opt->constant_ids);
     Py_CLEAR(opt->constant_list);
+    Py_CLEAR(opt->name_ids);
+    Py_CLEAR(opt->name_list);
     Py_CLEAR(opt->trace);
     while (opt->keys_count)
         PyDictKeysObject_DecRef(opt->keys[--opt->keys_count]);