From 39e5741cb2dac5ac6bc70762e656196f5e45feba Mon Sep 17 00:00:00 2001 From: Ingvar Stepanyan Date: Fri, 17 Jul 2020 02:23:00 +0100 Subject: [PATCH] Fix few more issues detected in MozJPEG wrapper --- codecs/mozjpeg_enc/mozjpeg_enc.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/codecs/mozjpeg_enc/mozjpeg_enc.cpp b/codecs/mozjpeg_enc/mozjpeg_enc.cpp index b1528550..28162601 100644 --- a/codecs/mozjpeg_enc/mozjpeg_enc.cpp +++ b/codecs/mozjpeg_enc/mozjpeg_enc.cpp @@ -103,8 +103,8 @@ val encode(std::string image_in, int image_width, int image_height, MozJpegOptio // fprintf(stderr, "can't open %s\n", filename); // exit(1); // } - uint8_t* output; - unsigned long size; + uint8_t* output = nullptr; + unsigned long size = 0; jpeg_mem_dest(&cinfo, &output, &size); /* Step 3: set parameters for compression */ @@ -203,6 +203,7 @@ val encode(std::string image_in, int image_width, int image_height, MozJpegOptio /* This is an important step since it will release a good deal of memory. */ jpeg_destroy_compress(&cinfo); + free(output); /* And we're done! */ return js_result;