[PATCH] mjpeg: Fix memory leak for the inital output buffer given for each frame

Yonit Halperin yhalperi at redhat.com
Thu May 10 02:26:01 PDT 2012


---
 server/mjpeg_encoder.c |    2 +-
 server/mjpeg_encoder.h |    2 ++
 2 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/server/mjpeg_encoder.c b/server/mjpeg_encoder.c
index 9c3d079..22a51c1 100644
--- a/server/mjpeg_encoder.c
+++ b/server/mjpeg_encoder.c
@@ -180,7 +180,7 @@ spice_jpeg_mem_dest(j_compress_ptr cinfo,
   dest->pub.term_destination = term_mem_destination;
   dest->outbuffer = outbuffer;
   dest->outsize = outsize;
-  dest->newbuffer = NULL;
+  dest->newbuffer = *outbuffer;
 
   if (*outbuffer == NULL || *outsize == 0) {
     /* Allocate initial buffer */
diff --git a/server/mjpeg_encoder.h b/server/mjpeg_encoder.h
index 91297d0..f9d5590 100644
--- a/server/mjpeg_encoder.h
+++ b/server/mjpeg_encoder.h
@@ -27,6 +27,8 @@ MJpegEncoder *mjpeg_encoder_new(void);
 void mjpeg_encoder_destroy(MJpegEncoder *encoder);
 
 uint8_t mjpeg_encoder_get_bytes_per_pixel(MJpegEncoder *encoder);
+/* if *dest != NULL, it must be allocated by malloc, since it can be freed
+ * during the ecoding */
 int mjpeg_encoder_start_frame(MJpegEncoder *encoder, SpiceBitmapFmt format,
                               int width, int height,
                               uint8_t **dest, size_t *dest_len);
-- 
1.7.7.6


--------------090403060200010202020201--


More information about the Spice-devel mailing list