diff options
author | g-coder <garima.g@samsung.com> | 2016-05-26 21:36:16 +0530 |
---|---|---|
committer | Bruce A. Mah <bmah@kitchenlab.org> | 2016-05-26 09:06:16 -0700 |
commit | 0da552c390c8332a53b5a39cdfbe6ffccd749189 (patch) | |
tree | 86e8792c11df518e5db65ba7a24d66cd184a1ec6 /src/iperf_util.c | |
parent | 8fcfc2479f8072c00798fcbea93309d41af5ef2a (diff) | |
download | iperf3-0da552c390c8332a53b5a39cdfbe6ffccd749189.tar.gz |
Safe programming practice. Added va_end. (#425)
In file iperf_util.c:
Function 'va_start' is called at line:327. But, 'va_end' is not called before returning from function 'iperf_json_printf()' at line:352 and line:355.
The va_end performs cleanup for the argp object initialized by a call to va_start. If va_end is not called before a function that calls va_start returns, the behavior is undefined.
Applied Fix: added va_end before returning from the function.
Diffstat (limited to 'src/iperf_util.c')
-rw-r--r-- | src/iperf_util.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/iperf_util.c b/src/iperf_util.c index 8413200..7142ee1 100644 --- a/src/iperf_util.c +++ b/src/iperf_util.c @@ -349,10 +349,13 @@ iperf_json_printf(const char *format, ...) j = cJSON_CreateString(va_arg(argp, char *)); break; default: + va_end(argp); return NULL; } - if (j == NULL) - return NULL; + if (j == NULL) { + va_end(argp); + return NULL; + } cJSON_AddItemToObject(o, name, j); np = name; break; |