From 3a5fdd0a3909fb1d88623bc2229ca7a3b7cbe7cb Mon Sep 17 00:00:00 2001 From: Ondrej Holy Date: Mon, 20 Aug 2018 09:10:49 +0200 Subject: [PATCH] rdtk: Fix leak found by covscan 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 | 3 ++- rdtk/librdtk/rdtk_nine_patch.c | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/rdtk/librdtk/rdtk_font.c b/rdtk/librdtk/rdtk_font.c index 97a13f16a..cf7ec6404 100644 --- a/rdtk/librdtk/rdtk_font.c +++ b/rdtk/librdtk/rdtk_font.c @@ -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); diff --git a/rdtk/librdtk/rdtk_nine_patch.c b/rdtk/librdtk/rdtk_nine_patch.c index 818332f7b..c6532e044 100644 --- a/rdtk/librdtk/rdtk_nine_patch.c +++ b/rdtk/librdtk/rdtk_nine_patch.c @@ -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); } }