summaryrefslogtreecommitdiffstats
path: root/libdwfl/cu.c
diff options
context:
space:
mode:
Diffstat (limited to 'libdwfl/cu.c')
-rw-r--r--libdwfl/cu.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libdwfl/cu.c b/libdwfl/cu.c
index 94bfad8d..4de66248 100644
--- a/libdwfl/cu.c
+++ b/libdwfl/cu.c
@@ -83,8 +83,11 @@ addrarange (Dwfl_Module *mod, Dwarf_Addr addr, struct dwfl_arange **arange)
/* Store the final array, which is probably much smaller than before. */
mod->naranges = naranges;
- mod->aranges = (realloc (aranges, naranges * sizeof aranges[0])
- ?: aranges);
+ if (naranges > 0)
+ mod->aranges = (realloc (aranges, naranges * sizeof aranges[0])
+ ?: aranges);
+ else if (aranges != NULL)
+ free (aranges);
mod->lazycu += naranges;
}