Skip to contentSkip to conversation

master - coverity: check malloc results

PATCH Zdenek Kabelac 1 participant 1 message Jun 27, 2017

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8e790702f12ddcb730f8dc43d3fdccf08e62aa45
Commit:        8e790702f12ddcb730f8dc43d3fdccf08e62aa45
Parent:        e907535ab977ea29319aeb015cec6c06729f7ce4
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Tue Jun 27 10:18:00 2017 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Tue Jun 27 12:15:42 2017 +0200

coverity: check malloc results

---
 tools/command.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
tools/command.c +9 -2
index a08d068..b8b38ad 100644
@@ -743,7 +743,11 @@ static void add_oo_definition_line(const char *name, const char *line)
 	char *start;
 
 	oo = &oo_lines[oo_line_count++];
-	oo->name = dm_strdup(name);
+
+	if (!(oo->name = dm_strdup(name))) {
+		log_error("Failer to duplicate name %s.", name);
+		return; /* FIXME: return code */
+	}
 
 	if ((colon = strchr(oo->name, ':')))
 		*colon = '\0';
@@ -753,7 +757,10 @@ static void add_oo_definition_line(const char *name, const char *line)
 	}
 
 	start = strchr(line, ':') + 2;
-	oo->line = dm_strdup(start);
+	if (!(oo->line = dm_strdup(start))) {
+		log_error("Failer to duplicate line %s.", start);
+		return;
+	}
 }
 
 /* Support OO_FOO: continuing on multiple lines. */