[all] general: fix possible memory leaks with realloc usage

This commit is contained in:
Geoffrey McRae
2025-03-09 02:56:20 +11:00
parent 5382a94945
commit a421329d9a
3 changed files with 20 additions and 10 deletions

View File

@@ -164,7 +164,14 @@ static int dl_iterate_phdr_callback(struct dl_phdr_info * info, size_t size, voi
ttl += hdr.p_memsz;
}
crash.ranges = realloc(crash.ranges, sizeof(*crash.ranges) * (crash.rangeCount + 1));
void * tmp = realloc(crash.ranges,
sizeof(*crash.ranges) * (crash.rangeCount + 1));
if (!tmp)
{
DEBUG_ERROR("out of memory");
return 1;
}
crash.ranges = tmp;
crash.ranges[crash.rangeCount].start = info->dlpi_addr;
crash.ranges[crash.rangeCount].end = info->dlpi_addr + ttl;
++crash.rangeCount;