Skip to content
Snippets Groups Projects
Unverified Commit 4901f8a1 authored by dkang's avatar dkang Committed by Beat Küng
Browse files

add execption check after malloc

parent 7779c0bd
No related branches found
No related tags found
No related merge requests found
......@@ -144,6 +144,11 @@ px4_task_t px4_task_spawn_cmd(const char *name, int scheduler, int priority, int
// not safe to pass stack data to the thread creation
pthdata_t *taskdata = (pthdata_t *)malloc(structsize + len);
if (taskdata == nullptr) {
return -ENOMEM;
}
memset(taskdata, 0, structsize + len);
unsigned long offset = ((unsigned long)taskdata) + structsize;
......
......@@ -147,6 +147,11 @@ px4_task_t px4_task_spawn_cmd(const char *name, int scheduler, int priority, int
// not safe to pass stack data to the thread creation
taskdata = (pthdata_t *)malloc(structsize + len);
if (taskdata == nullptr) {
return -ENOMEM;
}
offset = ((unsigned long)taskdata) + structsize;
taskdata->entry = entry;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment