eina_vpath_vdg: free locally allocated memory before return 95/189895/2
authorShinwoo Kim <cinoo.kim@samsung.com>
Fri, 21 Sep 2018 03:11:24 +0000 (03:11 +0000)
committerShinwoo Kim <cinoo.kim@samsung.com>
Fri, 21 Sep 2018 10:49:08 +0000 (10:49 +0000)
The eina_vpath_resolve could allocate memory and return it.
But the eina_xdg_env_init does not release it.

*Detected by static analysis with the Coverity
Differential Revision: https://phab.enlightenment.org/D7066

Change-Id: Ic243f70632dd731cf1cab426d1abfe013afa362b

src/lib/eina/eina_vpath_xdg.c

index 6a1d4d8..2d53304 100644 (file)
@@ -15,10 +15,10 @@ eina_xdg_env_init(void)
 {
    char buf[PATH_MAX];
    char *s;
-   const char *home;
+   char home[PATH_MAX];
    Eina_Vpath_Interface_User user;
 
-   home = eina_vpath_resolve("(:home:)/");
+   eina_vpath_resolve_snprintf(home, sizeof(home), "(:home:)/");
 
    memset(&user, 0, sizeof(Eina_Vpath_Interface_User));