[Lldb-commits] [PATCH] D147007: [lldb] Fix double free in python bindings error handling.
Jorge Gorbe Moya via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Mon Mar 27 15:14:06 PDT 2023
jgorbe created this revision.
jgorbe added reviewers: bulbazord, mib, labath.
jgorbe added a project: LLDB.
Herald added a subscriber: JDevlieghere.
Herald added a project: All.
jgorbe requested review of this revision.
If we have a `%typemap(freearg)` that frees the argument, we shouldn't
free it manually on an error path before calling `SWIG_fail`.
`SWIG_fail` will already free the memory in this case, and doing it
manually results in a double free.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D147007
Files:
lldb/bindings/python/python-typemaps.swig
Index: lldb/bindings/python/python-typemaps.swig
===================================================================
--- lldb/bindings/python/python-typemaps.swig
+++ lldb/bindings/python/python-typemaps.swig
@@ -17,7 +17,6 @@
PythonString py_str = list.GetItemAtIndex(i).AsType<PythonString>();
if (!py_str.IsAllocated()) {
PyErr_SetString(PyExc_TypeError, "list must contain strings");
- free($1);
SWIG_fail;
}
@@ -294,12 +293,10 @@
PyObject *o = PyList_GetItem($input, i);
if (!SetNumberFromPyObject($1[i], o)) {
PyErr_SetString(PyExc_TypeError, "list must contain numbers");
- free($1);
SWIG_fail;
}
if (PyErr_Occurred()) {
- free($1);
SWIG_fail;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147007.508811.patch
Type: text/x-patch
Size: 786 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230327/adc1969f/attachment.bin>
More information about the lldb-commits
mailing list