[PATCH 01/15] libtracefs: call va_end() before exiting tracefs_hist_set_sort_key()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Each invocation of va_start() must be matched by a corresponding
invocation of va_end() in the same function. If add_sort_key() fails,
tracefs_hist_set_sort_key() exits without calling it. Call va_end
after add_sort_key() fails.

Fixes a VARARGS error (CWE-237)

Signed-off-by: Jerome Marchand <jmarchan@xxxxxxxxxx>
---
 src/tracefs-hist.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/tracefs-hist.c b/src/tracefs-hist.c
index 2b4f17f..87287b5 100644
--- a/src/tracefs-hist.c
+++ b/src/tracefs-hist.c
@@ -596,8 +596,10 @@ int tracefs_hist_set_sort_key(struct tracefs_hist *hist,
 		if (!sort_key)
 			break;
 		tmp = add_sort_key(hist, sort_key, list);
-		if (!tmp)
+		if (!tmp) {
+			va_end(ap);
 			goto fail;
+		}
 		list = tmp;
 	}
 	va_end(ap);
-- 
2.44.0





[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux