]> www.infradead.org Git - mtd-utils.git/commitdiff
nanddump: don't leak copied command line arguments
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>
Sun, 10 Nov 2019 13:56:51 +0000 (14:56 +0100)
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>
Sun, 10 Nov 2019 14:30:04 +0000 (15:30 +0100)
For some command line flags, the argument string is copied. Simply
writing over the buffer leads to a resource leak if the same flag
is specified on the command line more than once.

This patch adds a free() call to the old buffer before overwriting
it with the new copy.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
nand-utils/nanddump.c

index 2f167bb37e206de16be060b118b7c33bcedf028b..841ed67596cfc9982afa17cf795747c5ada6bdf1 100644 (file)
@@ -162,6 +162,7 @@ static void process_options(int argc, char * const argv[])
                                start_addr = simple_strtoll(optarg, &error);
                                break;
                        case 'f':
+                               free(dumpfile);
                                dumpfile = xstrdup(optarg);
                                break;
                        case 'l':