[gimp/merge-requests/470: 3/5] xcf-load: g_free name in error cases to avoid leak




commit 4286445c8afbac56ae637adffd18480836ab05c5
Author: Andrzej Hunt <andrzej ahunt org>
Date:   Fri Aug 27 18:10:08 2021 +0200

    xcf-load: g_free name in error cases to avoid leak
    
    In all 3 cases:
     - xcf_read_string allocates a new string into name.
     - If an error is detected, we return early - name remains unused.
    Therefore we add g_free (name) to these early returns to avoid a leak.

 app/xcf/xcf-load.c | 3 +++
 1 file changed, 3 insertions(+)
---
diff --git a/app/xcf/xcf-load.c b/app/xcf/xcf-load.c
index ce58001ee9..58fe18c6fb 100644
--- a/app/xcf/xcf-load.c
+++ b/app/xcf/xcf-load.c
@@ -1954,6 +1954,7 @@ xcf_load_layer (XcfInfo    *info,
       break;
 
     default:
+      g_free (name);
       return NULL;
     }
 
@@ -1977,6 +1978,7 @@ xcf_load_layer (XcfInfo    *info,
         }
       else
         {
+          g_free (name);
           return NULL;
         }
     }
@@ -2830,6 +2832,7 @@ xcf_load_old_path (XcfInfo   *info,
     {
       g_printerr ("Unknown path type. Possibly corrupt XCF file");
 
+      g_free (name);
       return FALSE;
     }
 


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