From 8ecf0620a7bf11179c141787281911dbb17a2b52 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Fri, 6 Nov 2015 12:34:16 +0000 Subject: [PATCH] Prevented use of uninitialized variable in case of memory shortage. Coverity CID 28801. --- xorriso/iso_tree.c | 19 ++++++------------- xorriso/xorriso_timestamp.h | 2 +- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/xorriso/iso_tree.c b/xorriso/iso_tree.c index 6dc61f97..769e065b 100644 --- a/xorriso/iso_tree.c +++ b/xorriso/iso_tree.c @@ -1372,13 +1372,9 @@ int Xorriso_show_du_subs(struct XorrisO *xorriso, IsoDir *dir_node, off_t sub_size, report_size, mem= 0; char *path= NULL, *show_path= NULL, *sfe= NULL; - sfe= malloc(5*SfileadrL); - path= malloc(SfileadrL); - show_path= malloc(SfileadrL); - if(path==NULL || show_path==NULL || sfe==NULL) { - Xorriso_no_malloc_memory(xorriso, &sfe, 0); - {ret= -1; goto ex;} - } + Xorriso_alloc_meM(sfe, char, 5 * SfileadrL); + Xorriso_alloc_meM(path, char, SfileadrL); + Xorriso_alloc_meM(show_path, char, SfileadrL); *size= 0; ret= iso_dir_get_children(dir_node, &iter); @@ -1490,12 +1486,9 @@ much_too_long:; } ret= 1; ex:; - if(sfe!=NULL) - free(sfe); - if(path!=NULL) - free(path); - if(show_path!=NULL) - free(show_path); + Xorriso_free_meM(sfe); + Xorriso_free_meM(path); + Xorriso_free_meM(show_path); if(iter!=NULL) iso_dir_iter_free(iter); if(node_array!=NULL) diff --git a/xorriso/xorriso_timestamp.h b/xorriso/xorriso_timestamp.h index 7bbcdcbf..618e5e31 100644 --- a/xorriso/xorriso_timestamp.h +++ b/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2015.11.06.092940" +#define Xorriso_timestamP "2015.11.06.123344"