Permalink
Browse files

Merge remote-tracking branch 'jasonrose/master' into memleaks

  • Loading branch information...
2 parents 9521254 + 9ce2d8e commit 4b1769825456de6dd16c3c9b15a090ea1e10a76b @kkoopa kkoopa committed Aug 26, 2013
Showing with 18 additions and 0 deletions.
  1. +10 −0 src/Image.cc
  2. +8 −0 src/JPEGStream.h
View
@@ -346,6 +346,11 @@ Image::loaded() {
if (onload != NULL) {
onload->Call(0, NULL);
delete onload;
+ onload = NULL;
+ }
+ if (onerror != NULL) {
+ delete onerror;
+ onerror = NULL;
}
}
@@ -360,6 +365,11 @@ Image::error(Local<Value> err) {
Local<Value> argv[1] = { err };
onerror->Call(1, argv);
delete onerror;
+ onerror = NULL;
+ }
+ if (onload != NULL) {
+ delete onload;
+ onload = NULL;
}
}
View
@@ -96,6 +96,13 @@ jpeg_closure_dest(j_compress_ptr cinfo, closure_t * closure, int 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);
int h = cairo_image_surface_get_height(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);
}

0 comments on commit 4b17698

Please sign in to comment.