[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 02/03: src/libs/libgroff/relocate.cpp: Fix memory leak.
From: |
G. Branden Robinson |
Subject: |
[groff] 02/03: src/libs/libgroff/relocate.cpp: Fix memory leak. |
Date: |
Tue, 5 Jan 2021 23:55:38 -0500 (EST) |
gbranden pushed a commit to branch master
in repository groff.
commit c2f0e424e4a2bdcd287c8be9957daf93a581673a
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Wed Jan 6 15:43:57 2021 +1100
src/libs/libgroff/relocate.cpp: Fix memory leak.
* src/libs/libgroff/relocate.cpp (set_current_prefix) [_WIN32]: Allocate
memory from heap for `curr_prefix` only on Windows; on other systems,
this file's searchpath() is used to populate `curr_prefix`, and that
function (except on Windows) performs its own allocation. Fixes
memory leak noted by Ingo Schwarze.
---
ChangeLog | 9 ++++++++-
src/libs/libgroff/relocate.cpp | 2 +-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 03a23a8..75306ca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,7 +2,14 @@
* src/libs/libgroff/relocate.cpp (relocatep): Add assertion to
identify logic error if `curr_prefix` is unexpectedly a null
- pointer. See <https://savannah.gnu.org/bugs/?55475>.
+ pointer.
+ (set_current_prefix) [_WIN32]: Allocate memory from heap for
+ `curr_prefix` only on Windows; on other systems, this file's
+ searchpath() is used to populate `curr_prefix`, and that
+ function (except on Windows) performs its own allocation. Fixes
+ memory leak noted by Ingo Schwarze.
+
+ See <https://savannah.gnu.org/bugs/?55475>.
2021-01-06 Colin Watson <cjwatson@debian.org>
diff --git a/src/libs/libgroff/relocate.cpp b/src/libs/libgroff/relocate.cpp
index e505bdf..298f693 100644
--- a/src/libs/libgroff/relocate.cpp
+++ b/src/libs/libgroff/relocate.cpp
@@ -160,11 +160,11 @@ char *msw2posixpath(char *path)
void set_current_prefix()
{
char *pathextstr;
- curr_prefix = new char[path_name_max()];
// Obtain the full path of the current binary;
// using GetModuleFileName on MS-Windows,
// and searching along PATH on other systems.
#ifdef _WIN32
+ curr_prefix = new char[path_name_max()];
int len = GetModuleFileName(0, curr_prefix, path_name_max());
if (len)
len = GetShortPathName(curr_prefix, curr_prefix, path_name_max());
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 02/03: src/libs/libgroff/relocate.cpp: Fix memory leak.,
G. Branden Robinson <=