component/bt: add protection in GKI_getbuf to protect against memory allocation failure;

This commit is contained in:
wangmengyang 2016-11-25 00:05:39 +08:00
parent d50792dec9
commit dae40afffb

View File

@ -196,12 +196,17 @@ void GKI_init_q (BUFFER_Q *p_q)
void *GKI_getbuf (UINT16 size)
{
BUFFER_HDR_T *header = osi_malloc(size + BUFFER_HDR_SIZE);
header->status = BUF_STATUS_UNLINKED;
header->p_next = NULL;
header->Type = 0;
header->size = size;
assert(header != NULL);
if (header != NULL) {
header->status = BUF_STATUS_UNLINKED;
header->p_next = NULL;
header->Type = 0;
header->size = size;
return header + 1;
return header + 1;
} else {
return NULL;
}
}