mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-09 03:51:20 -03:00
Stop leaking the result of wrealpath
This commit is contained in:
16
expand.cpp
16
expand.cpp
@@ -1616,7 +1616,7 @@ static void expand_home_directory(wcstring &input)
|
|||||||
{
|
{
|
||||||
size_t tail_idx;
|
size_t tail_idx;
|
||||||
wcstring username = get_home_directory_name(input, &tail_idx);
|
wcstring username = get_home_directory_name(input, &tail_idx);
|
||||||
|
|
||||||
bool tilde_error = false;
|
bool tilde_error = false;
|
||||||
wcstring home;
|
wcstring home;
|
||||||
if (username.empty())
|
if (username.empty())
|
||||||
@@ -1639,18 +1639,18 @@ static void expand_home_directory(wcstring &input)
|
|||||||
home = str2wcstring(userinfo->pw_dir);
|
home = str2wcstring(userinfo->pw_dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wchar_t *realhome;
|
wchar_t *realhome = wrealpath(home, NULL);
|
||||||
realhome = wrealpath(home, NULL);
|
|
||||||
|
|
||||||
if (! tilde_error && realhome)
|
if (! tilde_error && realhome)
|
||||||
{
|
{
|
||||||
input.replace(input.begin(), input.begin() + tail_idx, realhome);
|
input.replace(input.begin(), input.begin() + tail_idx, realhome);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
input[0] = L'~';
|
input[0] = L'~';
|
||||||
}
|
}
|
||||||
|
free((void *)realhome);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user