From e0fac2e4a655864c6c125e28918798502fe9651d Mon Sep 17 00:00:00 2001 From: Angel Pons Date: Tue, 31 Mar 2020 15:02:02 +0200 Subject: 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 Reviewed-on: https://review.coreboot.org/c/flashrom/+/39972 Reviewed-by: Nico Huber Tested-by: build bot (Jenkins) --- cli_classic.c | 3 +++ 1 file changed, 3 insertions(+) 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: -- cgit v1.2.3