From: Youngbok Shin Date: Thu, 16 Mar 2017 01:44:02 +0000 (+0900) Subject: fix memory leak and uninitialized local variable issues X-Git-Tag: accepted/tizen/4.0/unified/20170816.012731~2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdownload-fonts-service.git;a=commitdiff_plain;h=6bdccca8c4bb0936d1c8a8b5fb0da140c7cbbf09 fix memory leak and uninitialized local variable issues - Memory leak from FontConfig Pattern pointer. - Uninitialized local variable can be problem when it checks address for free and file close. Change-Id: I5a23fbf2fa484a70cceaab9eb6cbda5d86cb02f1 (cherry picked from commit a48fac2edbac930a86955ad2ae0f169e22672c7f) --- diff --git a/pkgmgr_font/src/font_service_register.c b/pkgmgr_font/src/font_service_register.c index b059dbb..d36446a 100755 --- a/pkgmgr_font/src/font_service_register.c +++ b/pkgmgr_font/src/font_service_register.c @@ -185,8 +185,8 @@ FAIL: #define COPY_BUF_SIZE 16777216 static int copy_file(const char *srcpath, const char *destpath) { - FILE *in, *out; - char *buf; + FILE *in = NULL, *out = NULL; + char *buf = NULL; size_t len; if (!srcpath || !destpath) @@ -773,7 +773,9 @@ int COMMON_PKGMGR_PLUGIN_UNINSTALL(const char *pkgid, const char *appid, GList * fs = FcFontList(NULL, pat, os); FcPatternDestroy(pat); + pat = NULL; free(current_font_name); + current_font_name = NULL; if (fs) { @@ -826,6 +828,7 @@ int COMMON_PKGMGR_PLUGIN_UNINSTALL(const char *pkgid, const char *appid, GList * return do_uninstall(deletedir); FAIL: + if (pat) FcPatternDestroy(pat); elm_shutdown(); pkgmgrinfo_pkginfo_destroy_pkginfo(handle);