From c8a0a2229d484334ca3ed75652e7a10f6a3d1edf Mon Sep 17 00:00:00 2001 From: Jef Poskanzer Date: Thu, 12 Dec 2013 08:15:15 -0800 Subject: [PATCH] Added a check for malloc fail. Eventually we need to add a whole bunch more of these. --- src/iperf_api.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/iperf_api.c b/src/iperf_api.c index 67ad967..aa056ef 100644 --- a/src/iperf_api.c +++ b/src/iperf_api.c @@ -1363,6 +1363,11 @@ iperf_new_test() memset(test, 0, sizeof(struct iperf_test)); test->settings = (struct iperf_settings *) malloc(sizeof(struct iperf_settings)); + if (!test->settings) { + free(test); + i_errno = IENEWTEST; + return NULL; + } memset(test->settings, 0, sizeof(struct iperf_settings)); return test;