/* 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;