initialize dest in cmd_add_string() to not segfault on empty strings
[project/procd.git] / hotplug-rule.c
index b90ae52..1f3189d 100644 (file)
@@ -325,7 +325,7 @@ static void cmd_add_string(const char *pattern, struct blob_attr *msg)
        int len = 0;
        bool var = false;
 
-       blobmsg_alloc_string_buffer(&b, NULL, 1);
+       dest = blobmsg_alloc_string_buffer(&b, NULL, 1);
        str = alloca(strlen(pattern) + 1);
        strcpy(str, pattern);
        next = str;
@@ -467,7 +467,7 @@ rule_file_load(const char *filename)
                return NULL;
 
        obj = json_object_from_file((char *) filename);
-       if (!obj)
+       if (is_error(obj))
                return NULL;
 
        if (!json_object_is_type(obj, json_type_array)) {