rdtk: Fix leak found by covscan
authorOndrej Holy <oholy@redhat.com>
Mon, 20 Aug 2018 07:10:49 +0000 (09:10 +0200)
committerOndrej Holy <oholy@redhat.com>
Wed, 22 Aug 2018 12:34:02 +0000 (14:34 +0200)
leaked_storage: Variable "fontBaseFile" going out of scope leaks the storage it points to.
leaked_storage: Variable "image" going out of scope leaks the storage it points to.

rdtk/librdtk/rdtk_font.c
rdtk/librdtk/rdtk_nine_patch.c

index 97a13f1..cf7ec64 100644 (file)
@@ -612,7 +612,6 @@ rdtkFont* rdtk_font_new(rdtkEngine* engine, const char* path, const char* file)
 
        strcpy(fontDescriptorFile, fontBaseFile);
        strcpy(&fontDescriptorFile[length], ".xml");
-       free(fontBaseFile);
 
        if (!PathFileExistsA(fontImageFile))
                goto cleanup;
@@ -641,10 +640,12 @@ rdtkFont* rdtk_font_new(rdtkEngine* engine, const char* path, const char* file)
        if (status < 0)
                goto cleanup;
 
+       free(fontBaseFile);
        free(fontImageFile);
        free(fontDescriptorFile);
        return font;
 cleanup:
+       free(fontBaseFile);
        free(fontImageFile);
        free(fontDescriptorFile);
 
index 818332f..c6532e0 100644 (file)
@@ -390,6 +390,8 @@ int rdtk_nine_patch_engine_init(rdtkEngine* engine)
 
                        if (ninePatch)
                                rdtk_nine_patch_set_image(ninePatch, image);
+                       else
+                               winpr_image_free(image, TRUE);
                }
        }
 
@@ -414,6 +416,8 @@ int rdtk_nine_patch_engine_init(rdtkEngine* engine)
 
                        if (ninePatch)
                                rdtk_nine_patch_set_image(ninePatch, image);
+                       else
+                               winpr_image_free(image, TRUE);
                }
        }