mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-21 01:12:11 +00:00
add execption check after malloc
This commit is contained in:
@@ -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
|
// not safe to pass stack data to the thread creation
|
||||||
pthdata_t *taskdata = (pthdata_t *)malloc(structsize + len);
|
pthdata_t *taskdata = (pthdata_t *)malloc(structsize + len);
|
||||||
|
|
||||||
|
if (taskdata == nullptr) {
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
memset(taskdata, 0, structsize + len);
|
memset(taskdata, 0, structsize + len);
|
||||||
unsigned long offset = ((unsigned long)taskdata) + structsize;
|
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
|
// not safe to pass stack data to the thread creation
|
||||||
taskdata = (pthdata_t *)malloc(structsize + len);
|
taskdata = (pthdata_t *)malloc(structsize + len);
|
||||||
|
|
||||||
|
if (taskdata == nullptr) {
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
offset = ((unsigned long)taskdata) + structsize;
|
offset = ((unsigned long)taskdata) + structsize;
|
||||||
|
|
||||||
taskdata->entry = entry;
|
taskdata->entry = entry;
|
||||||
|
|||||||
Reference in New Issue
Block a user