fix memory leak and uninitialized local variable issues 65/119165/1
authorYoungbok Shin <youngb.shin@samsung.com>
Thu, 16 Mar 2017 01:44:02 +0000 (10:44 +0900)
committerYoungbok Shin <youngb.shin@samsung.com>
Thu, 16 Mar 2017 01:44:02 +0000 (10:44 +0900)
- Memory leak from FontConfig Pattern pointer.
- Uninitialized local variable can be problem
  when it checks address for free and file close.

Change-Id: I5a23fbf2fa484a70cceaab9eb6cbda5d86cb02f1

pkgmgr_font/src/font_service_register.c

index b059dbb..d36446a 100755 (executable)
@@ -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);