commit 6bedcb4622fbec92dc74b03ba1c2d8f78a260792
parent 121c2c5653ce8a51a02cff7d2ce348a9546f9e2c
Author: James Prestwood <prestwoj@gmail.com>
Date: Fri, 1 Mar 2024 11:40:56 -0800
client: fix two issues caught by static analysis
- va_end was not being called on an error condition
- An uninitialized struct was being accessed if ioctl failed
Diffstat:
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git 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);