ubusd: fix inverted check in ubusd_reply_add
[project/ubus.git] / examples / client.c
index b586eaffd1605f337b1e3f490c219fa2a5850505..7ef566347e540f8d9e096552b8244f6cc3a0e5f5 100644 (file)
@@ -106,8 +106,10 @@ static void test_count(struct uloop_timeout *timeout)
        count_to += count_progression;
 
        s = count_to_number(count_to);
-       if (!s)
+       if (!s) {
                fprintf(stderr, "Could not allocate memory to count up to '%u'\n", count_to);
+               return;
+       }
 
        fprintf(stderr, "Sending count up to '%u'; string has length '%u'\n",
                count_to, (uint32_t)strlen(s));
@@ -116,6 +118,7 @@ static void test_count(struct uloop_timeout *timeout)
        blobmsg_add_string(&b, "string", s);
 
        if (ubus_lookup_id(ctx, "test", &id)) {
+               free(s);
                fprintf(stderr, "Failed to look up test object\n");
                return;
        }