diff --git a/armsrc/fpgaloader.c b/armsrc/fpgaloader.c index 0b94bba45..63957067f 100644 --- a/armsrc/fpgaloader.c +++ b/armsrc/fpgaloader.c @@ -229,8 +229,10 @@ static bool reset_fpga_stream(int bitstream_version, z_streamp compressed_fpga_s compressed_fpga_stream->zalloc = &fpga_inflate_malloc; compressed_fpga_stream->zfree = &fpga_inflate_free; - inflateInit2(compressed_fpga_stream, 0); - + int res = inflateInit2(compressed_fpga_stream, 0); + if ( res < 0 ) + return false; + fpga_image_ptr = output_buffer; for (uint16_t i = 0; i < FPGA_BITSTREAM_FIXED_HEADER_SIZE; i++) diff --git a/armsrc/start.c b/armsrc/start.c index b5947bdf3..0b48fc601 100644 --- a/armsrc/start.c +++ b/armsrc/start.c @@ -48,7 +48,9 @@ static void uncompress_data_section(void) { data_section.opaque = NULL; // initialize zlib for inflate - inflateInit2(&data_section, 15); + int res = inflateInit2(&data_section, 15); + if ( res < 0 ) + return; // uncompress data segment to RAM inflate(&data_section, Z_FINISH); diff --git a/client/fpga_compress.c b/client/fpga_compress.c index 00e62d74b..cba92a99e 100644 --- a/client/fpga_compress.c +++ b/client/fpga_compress.c @@ -206,7 +206,9 @@ int zlib_decompress(FILE *infile, FILE *outfile) { compressed_fpga_stream.opaque = Z_NULL; ret = inflateInit2(&compressed_fpga_stream, 0); - + if ( res < 0 ) + return (EXIT_FAILURE); + do { if (compressed_fpga_stream.avail_in == 0) { compressed_fpga_stream.next_in = inbuf;