summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorCorentin Chary <corentincj@iksaif.net>2010-07-07 20:57:55 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2010-07-26 17:36:14 -0500
commitafcd0fa7d0658038442fdbc2170ac83fb9c07492 (patch)
tree30aa606ed28e5704c8acfac13f560cb27ef18c47 /ui
parent70e64903073c1770bbc6a8ab3f4407a6958e4906 (diff)
downloadqemu-afcd0fa7d0658038442fdbc2170ac83fb9c07492.tar.gz
qemu-afcd0fa7d0658038442fdbc2170ac83fb9c07492.tar.bz2
qemu-afcd0fa7d0658038442fdbc2170ac83fb9c07492.zip
vnc: tight: remove a memleak in send_jpeg_rect()
buf was never freed. Signed-off-by: Corentin Chary <corentincj@iksaif.net> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/vnc-enc-tight.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c
index ade8e5f846..4ff88a8b03 100644
--- a/ui/vnc-enc-tight.c
+++ b/ui/vnc-enc-tight.c
@@ -1247,8 +1247,6 @@ static int send_jpeg_rect(VncState *vs, int x, int y, int w, int h, int quality)
if (ds_get_bytes_per_pixel(vs->ds) == 1)
return send_full_color_rect(vs, w, h);
- buf = qemu_malloc(w * 3);
- row[0] = buf;
buffer_reserve(&vs->tight_jpeg, 2048);
cinfo.err = jpeg_std_error(&jerr);
@@ -1270,10 +1268,13 @@ static int send_jpeg_rect(VncState *vs, int x, int y, int w, int h, int quality)
jpeg_start_compress(&cinfo, true);
+ buf = qemu_malloc(w * 3);
+ row[0] = buf;
for (dy = 0; dy < h; dy++) {
jpeg_prepare_row(vs, buf, x, y + dy, w);
jpeg_write_scanlines(&cinfo, row, 1);
}
+ qemu_free(buf);
jpeg_finish_compress(&cinfo);
jpeg_destroy_compress(&cinfo);