ubus: Fix issues reported by static code analysis tool Klocwork
[project/ubus.git] / examples / server.c
index b8b751e715a8b82d5f0478a39c5ac73991678ec6..e0cde0bf3a8660941d34d0dcc29253f7fa0ad91e 100644 (file)
@@ -93,6 +93,9 @@ static int test_hello(struct ubus_context *ctx, struct ubus_object *obj,
                msgstr = blobmsg_data(tb[HELLO_MSG]);
 
        hreq = calloc(1, sizeof(*hreq) + strlen(format) + strlen(obj->name) + strlen(msgstr) + 1);
+       if (!hreq)
+               return UBUS_STATUS_UNKNOWN_ERROR;
+
        sprintf(hreq->data, format, obj->name, msgstr);
        ubus_defer_request(ctx, req, &hreq->req);
        hreq->timeout.cb = test_hello_reply;