Mark Shannon avatar Mark Shannon committed 9d434d0 Draft

Fix leak in trace_recorder_register

Comments (0)

Files changed (2)

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)

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]);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.