[PATCH spice-common 2/5] canvas: Remove possible leak on LZ decompression failure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



longjmp can happen in different places, even after the palette
is allocated so we need to free it if it got allocated.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 common/canvas_base.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/common/canvas_base.c b/common/canvas_base.c
index f4f301c..b9ba37c 100644
--- a/common/canvas_base.c
+++ b/common/canvas_base.c
@@ -783,15 +783,17 @@ static pixman_image_t *canvas_get_lz(CanvasBase *canvas, SpiceImage *image,
     int top_down;
     int stride_encoded;
     int stride;
-    int free_palette;
+    int free_palette = FALSE;
 
     if (setjmp(lz_data->jmp_env)) {
+        if (free_palette)  {
+            free(palette);
+        }
         free(decomp_buf);
         spice_warning("%s", lz_data->message_buf);
         return NULL;
     }
 
-    free_palette = FALSE;
     if (image->descriptor.type == SPICE_IMAGE_TYPE_LZ_RGB) {
         spice_return_val_if_fail(image->u.lz_rgb.data->num_chunks == 1, NULL); /* TODO: Handle chunks */
         comp_buf = image->u.lz_rgb.data->chunk[0].data;
-- 
2.14.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]