[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 16:07:55 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4a38d3326895: [lldb] Fix double free in python bindings error handling. (authored by jgorbe).
Changed prior to commit:
https://reviews.llvm.org/D147007?vs=508811&id=508827#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D147007/new/
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
@@ -1,4 +1,10 @@
-/* Typemap definitions, to allow SWIG to properly handle 'char**' data types. */
+/* Typemap definitions, to allow SWIG to properly handle 'char**' data types.
+
+NOTE: If there's logic to free memory in a %typemap(freearg), it will also be
+run if you call SWIG_fail on an error path. Don't manually free() an argument
+AND call SWIG_fail at the same time, because it will result in a double free.
+
+*/
%inline %{
@@ -17,7 +23,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 +299,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.508827.patch
Type: text/x-patch
Size: 1225 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230327/a638f88a/attachment.bin>
More information about the lldb-commits
mailing list