mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-05-23 18:26:47 +08:00
Fix memory leak in python.c:do_start_initialization
When intializing Python the path to the python binary is build the following way progname = concat (ldirname (python_libdir), SLASH_STRING, "bin", SLASH_STRING, "python", (char *) NULL); This is problematic as both concat and ldirname allocate memory for the string they return. Thus the memory allocated by ldirname cannot be accessed afterwards causing a memory leak. Fix it by temporarily storing libdir in a variable and xfree it after concat. gdb/ChangeLog: python/python.c (do_start_initialization): Fix memory leak.
This commit is contained in:

committed by
Andreas Arnez

parent
ad36c6ce7c
commit
3f2a3564b1
@ -1550,8 +1550,10 @@ do_start_initialization ()
|
||||
/foo/bin/python
|
||||
/foo/lib/pythonX.Y/...
|
||||
This must be done before calling Py_Initialize. */
|
||||
progname = concat (ldirname (python_libdir), SLASH_STRING, "bin",
|
||||
const char *libdir = ldirname (python_libdir);
|
||||
progname = concat (libdir, SLASH_STRING, "bin",
|
||||
SLASH_STRING, "python", (char *) NULL);
|
||||
xfree (libdir);
|
||||
#ifdef IS_PY3K
|
||||
oldloc = xstrdup (setlocale (LC_ALL, NULL));
|
||||
setlocale (LC_ALL, "");
|
||||
|
Reference in New Issue
Block a user