From 67d023281671d5449ef63ec4d9bafe43403e4d9e Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 4 Aug 2011 17:56:11 +0000 Subject: [PATCH] Add missing check for allocation failure Static analyzer discovered missing check. --- WHATS_NEW_DM | 1 + libdm/libdm-file.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index 25cb4ee67..0a376217e 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -1,5 +1,6 @@ Version 1.02.66 - =============================== + Add missing check for allocation failure _create_dir_recursive(). Add support for systemd file descriptor handover in dmeventd. Add support for new oom killer adjustment interface (oom_score_adj). Add systemd unit files for dmeventd. diff --git a/libdm/libdm-file.c b/libdm/libdm-file.c index 4edead9d3..91fdce02b 100644 --- a/libdm/libdm-file.c +++ b/libdm/libdm-file.c @@ -27,6 +27,11 @@ static int _create_dir_recursive(const char *dir) log_verbose("Creating directory \"%s\"", dir); /* Create parent directories */ orig = s = dm_strdup(dir); + if (!s) { + log_error("Failed to duplicate directory name."); + return 0; + } + while ((s = strchr(s, '/')) != NULL) { *s = '\0'; if (*orig) {