libubus: do not register/unregister with uloop during sync requests
[project/ubus.git] / examples / client.c
index b586eaf..7ef5663 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;
        }