binfmt: Check return pointer.

Function builtin_for_index may return NULL.
We must check this to prevent visit invalid address.

Signed-off-by: xiangdong6 <xiangdong6@xiaomi.com>
This commit is contained in:
xiangdong6 2022-09-03 13:10:23 +08:00 committed by Xiang Xiao
parent c5785ee9d5
commit 4cd4303c32

View File

@ -97,6 +97,12 @@ static int builtin_loadbinary(FAR struct binary_s *binp,
*/
builtin = builtin_for_index(index);
if (builtin == NULL)
{
berr("ERROR: %s is not a builtin application\n", filename);
return -ENOENT;
}
binp->entrypt = builtin->main;
binp->stacksize = builtin->stacksize;
binp->priority = builtin->priority;