ecore_file - finding exe path - if HOME is not set a leak could happen

this fixes CID 1039279
This commit is contained in:
Carsten Haitzler 2013-12-13 21:23:07 +09:00
parent e4b029da0b
commit f8b5dcf126
1 changed files with 6 additions and 2 deletions

View File

@ -857,7 +857,7 @@ ecore_file_ls(const char *dir)
EAPI char * EAPI char *
ecore_file_app_exe_get(const char *app) ecore_file_app_exe_get(const char *app)
{ {
char *p, *pp, *exe1 = NULL, *exe2 = NULL; char *p, *pp = NULL, *exe1 = NULL, *exe2 = NULL;
char *exe = NULL; char *exe = NULL;
int in_quot_dbl = 0, in_quot_sing = 0, restart = 0; int in_quot_dbl = 0, in_quot_sing = 0, restart = 0;
@ -901,7 +901,11 @@ restart:
exe1++; exe1++;
homedir = getenv("HOME"); homedir = getenv("HOME");
if (!homedir) return NULL; if (!homedir)
{
if (pp) free(pp);
return NULL;
}
len = strlen(homedir); len = strlen(homedir);
if (exe) free(exe); if (exe) free(exe);
exe = malloc(len + exe2 - exe1 + 2); exe = malloc(len + exe2 - exe1 + 2);