From 9ce2d8ebec9e52c8bf6ade4df7f5a41ec81a9d11 Mon Sep 17 00:00:00 2001 From: Jason Rose Date: Thu, 15 Aug 2013 17:23:01 -0700 Subject: [PATCH] Freeing custom buffer created during canvas jpeg streaming. --- src/JPEGStream.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/JPEGStream.h b/src/JPEGStream.h index 0e0738c..041b950 100644 --- a/src/JPEGStream.h +++ b/src/JPEGStream.h @@ -95,6 +95,13 @@ jpeg_closure_dest(j_compress_ptr cinfo, closure_t * closure, int bufsize){ cinfo->dest->free_in_buffer = dest->bufsize; } +void +jpeg_free_custom_allocations(j_compress_ptr cinfo){ + closure_destination_mgr * dest; + dest = (closure_destination_mgr *) cinfo->dest; + free(dest->buffer); +} + void write_to_jpeg_stream(cairo_surface_t *surface, int bufsize, int quality, bool progressive, closure_t *closure){ int w = cairo_image_surface_get_width(surface); @@ -136,6 +143,7 @@ write_to_jpeg_stream(cairo_surface_t *surface, int bufsize, int quality, bool pr sl++; } free(dst); + jpeg_free_custom_allocations(&cinfo); jpeg_finish_compress(&cinfo); jpeg_destroy_compress(&cinfo); }