From 37c2df71dd062318a314eb5da8063a2310168855 Mon Sep 17 00:00:00 2001 From: tmeissner Date: Tue, 5 May 2015 10:14:23 +0200 Subject: [PATCH] add check for return value of asprintf() --- 21st_century_c/process_dir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/21st_century_c/process_dir.c b/21st_century_c/process_dir.c index c05b5a2..1c830e0 100644 --- a/21st_century_c/process_dir.c +++ b/21st_century_c/process_dir.c @@ -31,8 +31,8 @@ int process_dir_r(filestruct level) { filestruct next_level = level; next_level.name = entry->d_name; - (void) asprintf(&next_level.fullname, "%s/%s", level.fullname, entry->d_name); - if (next_level.fullname == NULL) { + if ((asprintf(&next_level.fullname, "%s/%s", level.fullname, entry->d_name) == -1) || + (next_level.fullname == NULL)) { return 1; }