mirror of
https://github.com/SELinuxProject/selinux
synced 2025-01-08 14:40:14 +00:00
policycoreutils: fix potential NULL reference in load_checks
In load_checks(), add return check for malloc() to avoid NULL reference. Signed-off-by: Jie Lu <lujie54@huawei.com> Acked-by: James Carter <jwcart2@gmail.com>
This commit is contained in:
parent
013ecfd7fa
commit
1fe82e5cf5
@ -140,6 +140,8 @@ static void load_checks(char *pc[], int *npc, char *fc[], int *nfc)
|
|||||||
pc[*npc] =
|
pc[*npc] =
|
||||||
(char *)malloc((buf_len) *
|
(char *)malloc((buf_len) *
|
||||||
sizeof(char));
|
sizeof(char));
|
||||||
|
if (!pc[*npc])
|
||||||
|
break;
|
||||||
memcpy(pc[*npc], bufp, buf_len);
|
memcpy(pc[*npc], bufp, buf_len);
|
||||||
(*npc)++;
|
(*npc)++;
|
||||||
bufp = NULL;
|
bufp = NULL;
|
||||||
@ -150,6 +152,8 @@ static void load_checks(char *pc[], int *npc, char *fc[], int *nfc)
|
|||||||
fc[*nfc] =
|
fc[*nfc] =
|
||||||
(char *)malloc((buf_len) *
|
(char *)malloc((buf_len) *
|
||||||
sizeof(char));
|
sizeof(char));
|
||||||
|
if (!fc[*nfc])
|
||||||
|
break;
|
||||||
memcpy(fc[*nfc], bufp, buf_len);
|
memcpy(fc[*nfc], bufp, buf_len);
|
||||||
(*nfc)++;
|
(*nfc)++;
|
||||||
bufp = NULL;
|
bufp = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user