From: Jérôme Benoit Date: Wed, 29 Mar 2017 21:24:05 +0000 (+0200) Subject: TP 13 exo1: Only free when needed the array X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=1c0d8256d86aef5bd306481764601c0463b901b8;p=TD_C.git TP 13 exo1: Only free when needed the array Needed to fix the memory leaks in case of error Signed-off-by: Jérôme Benoit --- diff --git a/TP_13/exo1/lib/array.c b/TP_13/exo1/lib/array.c index c4e227d..4445ca8 100644 --- a/TP_13/exo1/lib/array.c +++ b/TP_13/exo1/lib/array.c @@ -15,7 +15,8 @@ int* create_tab(int tab[], unsigned tab_size) { } void free_tab(int tab[]) { - free(tab); + if (!tab) + free(tab); } /* we suppose both tabs are already created */