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));
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;
/* setup the policy pointers */
p = malloc(sizeof(struct blobmsg_policy) * plen);
+ if (!p)
+ return 1;
+
memset(p, 0, sizeof(struct blobmsg_policy) * plen);
m->policy = p;
lua_pushnil(L);
/* setup object pointers */
obj = malloc(sizeof(struct ubus_lua_object));
+ if (!obj)
+ return NULL;
+
memset(obj, 0, sizeof(struct ubus_lua_object));
obj->o.name = lua_tostring(L, -2);
/* setup type pointers */
obj->o.type = malloc(sizeof(struct ubus_object_type));
+ if (!obj->o.type) {
+ free(obj);
+ return NULL;
+ }
+
memset(obj->o.type, 0, sizeof(struct ubus_object_type));
obj->o.type->name = lua_tostring(L, -2);
obj->o.type->id = 0;
{
lua_State *L = (lua_State *)req->priv;
- if (!msg)
+ if (!msg && L)
lua_pushnil(L);
- ubus_lua_parse_blob_array(L, blob_data(msg), blob_len(msg), true);
+ if (msg && L)
+ ubus_lua_parse_blob_array(L, blob_data(msg), blob_len(msg), true);
}
static int
struct ubus_lua_event* event = NULL;
event = malloc(sizeof(struct ubus_lua_event));
+ if (!event)
+ return NULL;
+
memset(event, 0, sizeof(struct ubus_lua_event));
event->e.cb = ubus_event_handler;
{
ubus_init_string_tree(&patterns, true);
event_obj = ubusd_create_object_internal(NULL, UBUS_SYSTEM_OBJECT_EVENT);
- event_obj->recv_msg = ubusd_event_recv;
+ if (event_obj != NULL)
+ event_obj->recv_msg = ubusd_event_recv;
}
int rem;
type = calloc(1, sizeof(*type));
+ if (!type)
+ return NULL;
+
type->refcount = 1;
if (!ubus_alloc_id(&obj_types, &type->id, 0))
blob_put_int8(&b, UBUS_ATTR_ACTIVE, active);
ub = ubus_msg_from_blob(false);
+ if (!ub)
+ return;
+
ubus_msg_init(ub, UBUS_MSG_NOTIFY, ++obj->invoke_seq, 0);
ubus_msg_send(obj->client, ub, true);
}
blob_put_int32(&b, UBUS_ATTR_TARGET, s->target->id.id);
ub = ubus_msg_from_blob(false);
- ubus_msg_init(ub, UBUS_MSG_UNSUBSCRIBE, ++s->subscriber->invoke_seq, 0);
- ubus_msg_send(s->subscriber->client, ub, true);
+ if (ub != NULL) {
+ ubus_msg_init(ub, UBUS_MSG_UNSUBSCRIBE, ++s->subscriber->invoke_seq, 0);
+ ubus_msg_send(s->subscriber->client, ub, true);
+ }
ubus_unsubscribe(s);
}