diff options
author | Jakub Jelen <jjelen@redhat.com> | 2021-04-13 07:26:15 +0200 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2021-04-13 07:26:15 +0200 |
commit | 4c8be54cc430bbebd41fd7c452ff4ff9e8ff2bd5 (patch) | |
tree | 4f43bdc55d4f494af9cfcab931f14e1bcb9cf51d /tools/gpgsplit.c | |
parent | scd: Fix memory leaks. (diff) | |
download | gnupg2-4c8be54cc430bbebd41fd7c452ff4ff9e8ff2bd5.tar.xz gnupg2-4c8be54cc430bbebd41fd7c452ff4ff9e8ff2bd5.zip |
tools: Fix memory leaks.
* tools/gpgsplit.c (write_part): Free BLOB on error.
--
GnuPG-bug-id: 5393
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Diffstat (limited to 'tools/gpgsplit.c')
-rw-r--r-- | tools/gpgsplit.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/tools/gpgsplit.c b/tools/gpgsplit.c index 7257b63e1..cc7bf8ef5 100644 --- a/tools/gpgsplit.c +++ b/tools/gpgsplit.c @@ -582,7 +582,10 @@ write_part (FILE *fpin, unsigned long pktlen, { c = getc (fpin); if (c == EOF) - goto read_error; + { + xfree (blob); + goto read_error; + } blob[i] = c; } len = public_key_length (blob, pktlen); @@ -594,18 +597,27 @@ write_part (FILE *fpin, unsigned long pktlen, if ( (hdr[0] & 0x40) ) { if (write_new_header (fpout, pkttype, len)) - goto write_error; + { + xfree (blob); + goto write_error; + } } else { if (write_old_header (fpout, pkttype, len)) - goto write_error; + { + xfree (blob); + goto write_error; + } } for (i=0; i < len; i++) { if ( putc (blob[i], fpout) == EOF ) - goto write_error; + { + xfree (blob); + goto write_error; + } } goto ready; |