]> granicus.if.org Git - procps-ng/commitdiff
Coverity scan findings - memleaks, unused vars, potential nullptr dereferences
authorJan Rybar <jrybar@redhat.com>
Thu, 6 May 2021 14:30:54 +0000 (16:30 +0200)
committerJan Rybar <jrybar@redhat.com>
Thu, 6 May 2021 14:32:11 +0000 (16:32 +0200)
lib/test_process.c
pmap.c
watch.c

index e20b270de2f645b99b16de3dec48b349024fdf57..f8ff5ed043d064f9f9b44663edaafb1d4861f88c 100644 (file)
@@ -69,6 +69,7 @@ signal_handler(int signum, siginfo_t *siginfo, void *ucontext)
            exit(EXIT_FAILURE);
     }
 
+    free(signame);
 }
 
 int main(int argc, char *argv[])
diff --git a/pmap.c b/pmap.c
index 49a2a6a863de3cd4388e580f2a3749cf278ae36b..d8565fc3cf9d93906490fcb82f00304ad51ad202 100644 (file)
--- a/pmap.c
+++ b/pmap.c
@@ -346,6 +346,9 @@ static void print_extended_maps (FILE *f)
                        if (listnode == NULL) {
                                assert(firstmapping == 2);
                                listnode = calloc(1, sizeof *listnode);
+                               if (listnode == NULL)
+                                       xerrx(EXIT_FAILURE, _("ERROR: memory allocation failed"));
+
                                if (listhead == NULL) {
                                        assert(listtail == NULL);
                                        listhead = listnode;
diff --git a/watch.c b/watch.c
index 1a95454e3c81dded6dc1d73b18fabceef9324c92..772879cd2d7612a29034c3f6134c5f74c7444dc2 100644 (file)
--- a/watch.c
+++ b/watch.c
@@ -124,8 +124,6 @@ static void reset_ansi(void)
 
 static void init_ansi_colors(void)
 {
-       int color;
-
        short ncurses_colors[] = {
                -1, COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_YELLOW,
                COLOR_BLUE, COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE
@@ -172,6 +170,9 @@ static int process_ansi_color_escape_sequence(char** escape_sequence) {
        // ESC[ 48;2;⟨r⟩;⟨g⟩;⟨b⟩ m Select RGB background color
        int num;
 
+       if (!escape_sequence)
+               return 0; /* avoid NULLPTR dereference, return "not understood" */
+
        if ((*escape_sequence)[0] != ';')
                return 0; /* not understood */