Alex Henrie : dbghelp: Fix memory leak on error path in dwarf2_read_range (cppcheck).
Alexandre Julliard
julliard at winehq.org
Wed Feb 2 16:38:04 CST 2022
Module: wine
Branch: master
Commit: 950792ae2b60d82ed101baa00b7bcc0dd9ba4ad8
URL: https://source.winehq.org/git/wine.git/?a=commit;h=950792ae2b60d82ed101baa00b7bcc0dd9ba4ad8
Author: Alex Henrie <alexhenrie24 at gmail.com>
Date: Wed Feb 2 00:23:13 2022 -0700
dbghelp: Fix memory leak on error path in dwarf2_read_range (cppcheck).
Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/dbghelp/dwarf.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/dlls/dbghelp/dwarf.c b/dlls/dbghelp/dwarf.c
index 7472b6070e6..fc88b741a56 100644
--- a/dlls/dbghelp/dwarf.c
+++ b/dlls/dbghelp/dwarf.c
@@ -1289,6 +1289,7 @@ static struct addr_range* dwarf2_get_ranges(const dwarf2_debug_info_t* di, unsig
{
struct attribute range;
struct addr_range* ranges;
+ struct addr_range* new_ranges;
if (dwarf2_find_attribute(di, DW_AT_ranges, &range))
{
@@ -1312,8 +1313,13 @@ static struct addr_range* dwarf2_get_ranges(const dwarf2_debug_info_t* di, unsig
if (*num_ranges >= alloc)
{
alloc *= 2;
- ranges = realloc(ranges, sizeof(struct addr_range) * alloc);
- if (!ranges) return NULL;
+ new_ranges = realloc(ranges, sizeof(struct addr_range) * alloc);
+ if (!new_ranges)
+ {
+ free(ranges);
+ return NULL;
+ }
+ ranges = new_ranges;
}
ranges[*num_ranges].low = di->unit_ctx->compiland->address + low;
ranges[*num_ranges].high = di->unit_ctx->compiland->address + high;
More information about the wine-cvs
mailing list