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

pull/468/merge
wangmengyang 2016-11-25 00:05:39 +08:00
rodzic d50792dec9
commit dae40afffb
1 zmienionych plików z 10 dodań i 5 usunięć

Wyświetl plik

@ -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;
}
}