From a9fb6db249368a76c5b89a55aa0d7bd85733f975 Mon Sep 17 00:00:00 2001 From: hans Date: Wed, 26 Aug 2015 16:39:54 +0200 Subject: [PATCH] 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. --- src/bsd/tunemu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/bsd/tunemu.c b/src/bsd/tunemu.c index 1ce90074..90873d7b 100644 --- a/src/bsd/tunemu.c +++ b/src/bsd/tunemu.c @@ -33,6 +33,7 @@ #include #include #include +#include #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); } }