]> 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)
committerCraig Small <csmall@dropbear.xyz>
Mon, 10 May 2021 10:09:20 +0000 (20:09 +1000)
lib/test_process.c
pmap.c
watch.c

index 7ba046e003696b795a594d749119bfbb5715d82b..91d7dbf35c43c09eb5715b8bfa2a320491d7ffee 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 ff28947754aaa47c5a06dbe38ff7c219142db9be..042d9dc0e34e53fafddfa5005144b9d05af83adf 100644 (file)
--- a/pmap.c
+++ b/pmap.c
@@ -352,6 +352,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 82b80736dcf1dc66681b0c358399334ba107c8d5..0ba6b3fc4612989fc464d2beb2e7dd8a66ce5f57 100644 (file)
--- a/watch.c
+++ b/watch.c
@@ -125,8 +125,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
@@ -173,6 +171,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 */