ccf2cd
commit a1bc3bf207c64e2a26d8a7a3c20dd960e0e5c545
ccf2cd
Author: Jan Rybar <jrybar@redhat.com>
ccf2cd
Date:   Thu May 6 16:30:54 2021 +0200
ccf2cd
ccf2cd
    Coverity scan findings - memleaks, unused vars, potential nullptr dereferences
ccf2cd
ccf2cd
diff --git a/lib/test_process.c b/lib/test_process.c
ccf2cd
index e20b270d..f8ff5ed0 100644
ccf2cd
--- a/lib/test_process.c
ccf2cd
+++ b/lib/test_process.c
ccf2cd
@@ -69,6 +69,7 @@ signal_handler(int signum, siginfo_t *siginfo, void *ucontext)
ccf2cd
 	    exit(EXIT_FAILURE);
ccf2cd
     }
ccf2cd
 
ccf2cd
+    free(signame);
ccf2cd
 }
ccf2cd
 
ccf2cd
 int main(int argc, char *argv[])
ccf2cd
diff --git a/pmap.c b/pmap.c
ccf2cd
index 49a2a6a8..d8565fc3 100644
ccf2cd
--- a/pmap.c
ccf2cd
+++ b/pmap.c
ccf2cd
@@ -346,6 +346,9 @@ static void print_extended_maps (FILE *f)
ccf2cd
 			if (listnode == NULL) {
ccf2cd
 				assert(firstmapping == 2);
ccf2cd
 				listnode = calloc(1, sizeof *listnode);
ccf2cd
+				if (listnode == NULL)
ccf2cd
+					xerrx(EXIT_FAILURE, _("ERROR: memory allocation failed"));
ccf2cd
+
ccf2cd
 				if (listhead == NULL) {
ccf2cd
 					assert(listtail == NULL);
ccf2cd
 					listhead = listnode;
ccf2cd
diff --git a/watch.c b/watch.c
ccf2cd
index 1a95454e..772879cd 100644
ccf2cd
--- a/watch.c
ccf2cd
+++ b/watch.c
ccf2cd
@@ -124,8 +124,6 @@ static void reset_ansi(void)
ccf2cd
 
ccf2cd
 static void init_ansi_colors(void)
ccf2cd
 {
ccf2cd
-	int color;
ccf2cd
-
ccf2cd
 	short ncurses_colors[] = {
ccf2cd
 		-1, COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_YELLOW,
ccf2cd
 		COLOR_BLUE, COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE
ccf2cd
@@ -172,6 +170,9 @@ static int process_ansi_color_escape_sequence(char** escape_sequence) {
ccf2cd
 	// ESC[ 48;2;⟨r⟩;⟨g⟩;⟨b⟩ m Select RGB background color
ccf2cd
 	int num;
ccf2cd
 
ccf2cd
+	if (!escape_sequence)
ccf2cd
+		return 0; /* avoid NULLPTR dereference, return "not understood" */
ccf2cd
+
ccf2cd
 	if ((*escape_sequence)[0] != ';')
ccf2cd
 		return 0; /* not understood */
ccf2cd