From ba7422a1ed25f3b967a5a4919cbc9030d14384c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Thu, 26 May 2016 19:53:17 +0200 Subject: [PATCH] Fix leak of data when streaming JPEG --- src/JPEGStream.h | 2 +- test/canvas.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/JPEGStream.h b/src/JPEGStream.h index bf43ae4..edc887e 100644 --- a/src/JPEGStream.h +++ b/src/JPEGStream.h @@ -53,7 +53,7 @@ term_closure_destination(j_compress_ptr cinfo){ closure_destination_mgr *dest = (closure_destination_mgr *) cinfo->dest; /* emit remaining data */ - Local buf = Nan::NewBuffer((char *)dest->buffer, dest->bufsize).ToLocalChecked(); + Local buf = Nan::NewBuffer((char *)dest->buffer, dest->bufsize - dest->pub.free_in_buffer).ToLocalChecked(); Local data_argv[2] = { Nan::Null() diff --git a/test/canvas.test.js b/test/canvas.test.js index 8821aed..dedf874 100644 --- a/test/canvas.test.js +++ b/test/canvas.test.js @@ -817,7 +817,7 @@ describe('Canvas', function () { bytes += chunk.length; }); stream.on('end', function(){ - assert.equal(bytes, 8192); + assert.equal(bytes, 5427); done(); }); stream.on('error', function(err) {