mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
component/bt: add protection in GKI_getbuf to protect against memory allocation failure;
This commit is contained in:
parent
d50792dec9
commit
dae40afffb
@ -196,12 +196,17 @@ void GKI_init_q (BUFFER_Q *p_q)
|
|||||||
void *GKI_getbuf (UINT16 size)
|
void *GKI_getbuf (UINT16 size)
|
||||||
{
|
{
|
||||||
BUFFER_HDR_T *header = osi_malloc(size + BUFFER_HDR_SIZE);
|
BUFFER_HDR_T *header = osi_malloc(size + BUFFER_HDR_SIZE);
|
||||||
header->status = BUF_STATUS_UNLINKED;
|
assert(header != NULL);
|
||||||
header->p_next = NULL;
|
if (header != NULL) {
|
||||||
header->Type = 0;
|
header->status = BUF_STATUS_UNLINKED;
|
||||||
header->size = size;
|
header->p_next = NULL;
|
||||||
|
header->Type = 0;
|
||||||
|
header->size = size;
|
||||||
|
|
||||||
return header + 1;
|
return header + 1;
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user