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>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/39972
Original-Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/71733
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
diff --git a/cli_classic.c b/cli_classic.c
index 7f6887c..5bdfa01 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -275,6 +275,9 @@
}
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: