forked from Archive/PX4-Autopilot
add execption check after malloc
This commit is contained in:
parent
7779c0bd69
commit
4901f8a1dc
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue