diff --git a/src/iperf_client_api.c b/src/iperf_client_api.c index f1dfeb1..8b6e2a9 100644 --- a/src/iperf_client_api.c +++ b/src/iperf_client_api.c @@ -54,6 +54,11 @@ int iperf_create_streams(struct iperf_test *test, int sender) { + if (NULL == test) + { + iperf_err(NULL, "No test\n"); + return -1; + } int i, s; #if defined(HAVE_TCP_CONGESTION) int saved_errno; @@ -158,6 +163,12 @@ create_client_timers(struct iperf_test * test) { struct iperf_time now; TimerClientData cd; + if (NULL == test) + { + iperf_err(NULL, "No test\n"); + i_errno = IEINITTEST; + return -1; + } if (iperf_time_now(&now) < 0) { i_errno = IEINITTEST; @@ -213,6 +224,11 @@ create_client_omit_timer(struct iperf_test * test) { struct iperf_time now; TimerClientData cd; + if (NULL == test) + { + iperf_err(NULL, "No test\n"); + return -1; + } if (test->omit == 0) { test->omit_timer = NULL; @@ -239,6 +255,12 @@ iperf_handle_message_client(struct iperf_test *test) int rval; int32_t err; + if (NULL == test) + { + iperf_err(NULL, "No test\n"); + i_errno = IEINITTEST; + return -1; + } /*!!! Why is this read() and not Nread()? */ if ((rval = read(test->ctrl_sck, (char*) &test->state, sizeof(signed char))) <= 0) { if (rval == 0) { @@ -334,6 +356,11 @@ iperf_handle_message_client(struct iperf_test *test) int iperf_connect(struct iperf_test *test) { + if (NULL == test) + { + iperf_err(NULL, "No test\n"); + return -1; + } FD_ZERO(&test->read_set); FD_ZERO(&test->write_set); @@ -436,6 +463,11 @@ iperf_connect(struct iperf_test *test) int iperf_client_end(struct iperf_test *test) { + if (NULL == test) + { + iperf_err(NULL, "No test\n"); + return -1; + } struct iperf_stream *sp; /* Close all stream sockets */ @@ -476,6 +508,12 @@ iperf_run_client(struct iperf_test * test) int64_t timeout_us; int64_t rcv_timeout_us; + if (NULL == test) + { + iperf_err(NULL, "No test\n"); + return -1; + } + if (test->logfile) if (iperf_open_logfile(test) < 0) return -1; diff --git a/src/iperf_error.c b/src/iperf_error.c index 4777075..6c93cc3 100644 --- a/src/iperf_error.c +++ b/src/iperf_error.c @@ -59,7 +59,7 @@ iperf_err(struct iperf_test *test, const char *format, ...) vsnprintf(str, sizeof(str), format, argp); if (test != NULL && test->json_output && test->json_top != NULL) cJSON_AddStringToObject(test->json_top, "error", str); - else + else { if (test && test->outfile && test->outfile != stdout) { if (ct) { fprintf(test->outfile, "%s", ct); @@ -72,6 +72,7 @@ iperf_err(struct iperf_test *test, const char *format, ...) } fprintf(stderr, "iperf3: %s\n", str); } + } va_end(argp); }