add malloc check

malloc can fail. check for errors or use xmalloc.
since this is bsd only, it is safe to use err and err.h.
This commit is contained in:
hans 2015-08-26 16:39:54 +02:00
parent 569b1dbf15
commit a9fb6db249

View file

@ -33,6 +33,7 @@
#include <stdint.h>
#include <ctype.h>
#include <fcntl.h>
#include <err.h>
#define PPPPROTO_CTL 1
@ -259,8 +260,8 @@ static void allocate_data_buffer(int size)
if (data_buffer_length < size)
{
free(data_buffer);
data_buffer_length = size;
data_buffer = malloc(data_buffer_length);
if ((data_buffer = malloc(size)) == NULL)
err(1, NULL);
}
}