Check failed malloc

FossilOrigin-Name: a8cbc5d153043c53e759567e618c4df9052c2187cdf866cf0ef5f25eb17efeec
This commit is contained in:
7u83@mail.ru 2016-03-30 06:37:55 +00:00
parent f1807c2867
commit 84535ae02f

View File

@ -97,6 +97,10 @@ static struct mbag_item * get(const uint8_t *src,int len)
return NULL; return NULL;
uint8_t *data = malloc(len+1); uint8_t *data = malloc(len+1);
if (!data){
free (item);
return NULL;
}
*data=len; *data=len;
memcpy(data+1,src,len); memcpy(data+1,src,len);
item->data=data; item->data=data;