From 00067fb64a5105a8ad03e33275f0d453e725a13c Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Fri, 10 Feb 2012 13:52:05 +0000 Subject: [PATCH] Add test for failing allocation Avoid memcpy to NULL if realloc fails. --- WHATS_NEW_DM | 1 + libdm/mm/dbg_malloc.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index af1fafb36..5b42f777e 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -1,5 +1,6 @@ Version 1.02.70 - =================================== + Add missing test for failing allocation in dm_realloc() code. Add test for memory allocation failures in regex matcher code. Simplify dm_task_set_geometry() and use dm_asprintf(). Set all parameters to 0 for dm_get_next_target() for NULL return. diff --git a/libdm/mm/dbg_malloc.c b/libdm/mm/dbg_malloc.c index 084932a20..fe8f5a99d 100644 --- a/libdm/mm/dbg_malloc.c +++ b/libdm/mm/dbg_malloc.c @@ -192,7 +192,7 @@ void *dm_realloc_aux(void *p, unsigned int s, const char *file, int line) r = dm_malloc_aux_debug(s, file, line); - if (p) { + if (r && p) { memcpy(r, p, mb->length); dm_free_aux(p); }