summaryrefslogtreecommitdiffstats
path: root/tools/gpgsplit.c
diff options
context:
space:
mode:
authorJakub Jelen <jjelen@redhat.com>2021-04-13 07:26:15 +0200
committerNIIBE Yutaka <gniibe@fsij.org>2021-04-13 07:26:15 +0200
commit4c8be54cc430bbebd41fd7c452ff4ff9e8ff2bd5 (patch)
tree4f43bdc55d4f494af9cfcab931f14e1bcb9cf51d /tools/gpgsplit.c
parentscd: Fix memory leaks. (diff)
downloadgnupg2-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.c20
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;