summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAngel Pons <th3fanbus@gmail.com>2020-03-31 15:02:02 +0200
committerAngel Pons <th3fanbus@gmail.com>2020-04-14 23:14:27 +0000
commite0fac2e4a655864c6c125e28918798502fe9651d (patch)
treedce32166392f0ccadaad552a209a651486f5659d
parentf572b50ec7cb35224e17e3c702a96cbcbaefc417 (diff)
downloadflashrom-e0fac2e4a655864c6c125e28918798502fe9651d.tar.gz
flashrom-e0fac2e4a655864c6c125e28918798502fe9651d.tar.bz2
flashrom-e0fac2e4a655864c6c125e28918798502fe9651d.zip
cli_classic.c: Prevent memory leak
If the `--flash-contents` switch is specified more than once, it will result in a memory leak. Therefore, allow this option only once. Change-Id: I530933c9a6431580fe4645396bb363939472a80a Signed-off-by: Angel Pons <th3fanbus@gmail.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/39972 Reviewed-by: Nico Huber <nico.h@gmx.de> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
-rw-r--r--cli_classic.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/cli_classic.c b/cli_classic.c
index 73cc41791..967ff5003 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -273,6 +273,9 @@ int main(int argc, char *argv[])
}
break;
case OPTION_FLASH_CONTENTS:
+ if (referencefile)
+ cli_classic_abort_usage("Error: --flash-contents specified more than once."
+ "Aborting.\n");
referencefile = strdup(optarg);
break;
case OPTION_FLASH_NAME: