From f6632c1ef42dfb4d16205fe59b9b501b6fb0ce33 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 12 Mar 2012 14:15:04 +0000 Subject: Fix error path for create_toolcontext Never return unfinished toolcontext - since error path is hit on various stages of initialization we cannot leave it partially uninitialized, since we would need to spread many more test across the code for config_valid. Instead return NULL and properly release udev library resources as well. --- lib/commands/toolcontext.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/commands') diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c index da7285db9..23617829b 100644 --- a/lib/commands/toolcontext.c +++ b/lib/commands/toolcontext.c @@ -1371,6 +1371,11 @@ struct cmd_context *create_toolcontext(unsigned is_long_lived, cmd->config_valid = 1; out: + if (cmd->config_valid != 1) { + destroy_toolcontext(cmd); + cmd = NULL; + } + return cmd; } -- cgit v1.2.1