Angel Pons submitted this change.

View Change

Approvals: build bot (Jenkins): Verified Nico Huber: Looks good to me, approved
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>
---
M cli_classic.c
1 file changed, 3 insertions(+), 0 deletions(-)

diff --git a/cli_classic.c b/cli_classic.c
index 73cc417..967ff50 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -273,6 +273,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:

To view, visit change 39972. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I530933c9a6431580fe4645396bb363939472a80a
Gerrit-Change-Number: 39972
Gerrit-PatchSet: 3
Gerrit-Owner: Angel Pons <th3fanbus@gmail.com>
Gerrit-Reviewer: Angel Pons <th3fanbus@gmail.com>
Gerrit-Reviewer: David Hendricks <david.hendricks@gmail.com>
Gerrit-Reviewer: Nico Huber <nico.h@gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter@users.sourceforge.net>
Gerrit-MessageType: merged