1
0
Fork 0
mirror of https://github.com/deltachat/deltachat-core.git synced 2025-10-04 18:29:19 +02:00

fix memory leak in netpgp's compression/decompression routines

This commit is contained in:
B. Petersen 2017-11-24 00:12:00 +01:00
parent 889b823202
commit 516b259da5

View file

@ -359,9 +359,6 @@ pgp_decompress(pgp_region_t *region, pgp_stream_t *stream,
#endif #endif
default: default:
PGP_ERROR_1(&stream->errors,
PGP_E_ALG_UNSUPPORTED_COMPRESS_ALG,
"Compression algorithm %d is not yet supported", type);
return 0; return 0;
} }
@ -392,9 +389,6 @@ pgp_decompress(pgp_region_t *region, pgp_stream_t *stream,
#endif #endif
default: default:
PGP_ERROR_1(&stream->errors,
PGP_E_ALG_UNSUPPORTED_COMPRESS_ALG,
"Compression algorithm %d is not yet supported", type);
return 0; return 0;
} }
@ -402,6 +396,24 @@ pgp_decompress(pgp_region_t *region, pgp_stream_t *stream,
pgp_reader_pop(stream); pgp_reader_pop(stream);
// EDIT BY MR - fix memory leak
switch (type) {
case PGP_C_ZIP:
case PGP_C_ZLIB:
inflateEnd(&z.zstream);
break;
#ifdef HAVE_BZLIB_H
case PGP_C_BZIP2:
BZ2_bzDecompressEnd(&bz.bzstream);
break;
#endif
default:
return 0;
}
// /EDIT BY MR - fix memory leak
return ret; return ret;
} }
@ -483,6 +495,7 @@ pgp_writez(pgp_output_t *out, const uint8_t *data, const unsigned len)
pgp_write_scalar(out, PGP_C_ZLIB, 1) && pgp_write_scalar(out, PGP_C_ZLIB, 1) &&
pgp_write(out, zip->dst, (unsigned)zip->stream.total_out); pgp_write(out, zip->dst, (unsigned)zip->stream.total_out);
deflateEnd(&zip->stream); // EDIT BY MR: fix memory leak
free(zip->src); free(zip->src);
free(zip->dst); free(zip->dst);
free(zip); free(zip);