diff mbox series

[4/4] client: fix two issues caught by static analysis

Message ID 20240301194056.1665549-4-prestwoj@gmail.com (mailing list archive)
State New
Headers show
Series [1/4] p2p: check connected peer before processing request | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-ci-gitlint success GitLint

Commit Message

James Prestwood March 1, 2024, 7:40 p.m. UTC
- va_end was not being called on an error condition
 - An uninitialized struct was being accessed if ioctl failed
---
 client/display.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/client/display.c b/client/display.c
index 64125934..83214c86 100644
--- a/client/display.c
+++ b/client/display.c
@@ -230,7 +230,8 @@  static void display_refresh_check_feasibility(void)
 {
 	const struct winsize ws;
 
-	ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws);
+	if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) < 0)
+		return;
 
 	if (ws.ws_col < LINE_LEN - 1) {
 		if (display_refresh.enabled) {
@@ -564,8 +565,6 @@  void display_table_row(const char *margin, unsigned int ncolumns, ...)
 		str += entry_append(e, str);
 	}
 
-	va_end(va);
-
 	display("%s\n", buf);
 	str = buf;
 
@@ -591,6 +590,8 @@  void display_table_row(const char *margin, unsigned int ncolumns, ...)
 	}
 
 done:
+	va_end(va);
+
 	for (i = 0; i < ncolumns; i++) {
 		if (entries[i].color)
 			l_free(entries[i].color);