From 5580cac5502cd518adad0a3682fd53aeeaf86a86 Mon Sep 17 00:00:00 2001
From: Frediano Ziglio <fziglio@redhat.com>
Date: Thu, 17 Sep 2015 15:01:05 +0100
Subject: [PATCH 57/57] Prevent leak if size from red_get_data_chunks don't
 match in red_get_image

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
---
 server/red_parse_qxl.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/server/red_parse_qxl.c b/server/red_parse_qxl.c
index 8e3dd55..bd0c408 100644
--- a/server/red_parse_qxl.c
+++ b/server/red_parse_qxl.c
@@ -530,6 +530,7 @@ static SpiceImage *red_get_image(RedMemSlotInfo *slots, int group_id,
                                        &chunks, qxl->bitmap.data);
             spice_assert(size == bitmap_size);
             if (size != bitmap_size) {
+                red_put_data_chunks(&chunks);
                 goto error;
             }
             red->u.bitmap.data = red_get_image_data_chunked(slots, group_id,
@@ -550,6 +551,7 @@ static SpiceImage *red_get_image(RedMemSlotInfo *slots, int group_id,
                                        &chunks, (QXLDataChunk *)qxl->quic.data);
         spice_assert(size == red->u.quic.data_size);
         if (size != red->u.quic.data_size) {
+            red_put_data_chunks(&chunks);
             goto error;
         }
         red->u.quic.data = red_get_image_data_chunked(slots, group_id,
-- 
2.4.3

