aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2015-01-20 01:04:01 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2015-01-20 01:04:07 -0800
commitb0cbad84f4f2570d5742d0bbd82718ef1908d2a7 (patch)
treee38dbfcb200cd49e7ffeda2e40731805e255bd5b
parentf920be5ea30ca05b8da1069d8830df02d3213c9a (diff)
Stop leaking the result of wrealpath
-rw-r--r--expand.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/expand.cpp b/expand.cpp
index ed6b6e6d..c908cd9d 100644
--- a/expand.cpp
+++ b/expand.cpp
@@ -1616,7 +1616,7 @@ static void expand_home_directory(wcstring &input)
{
size_t tail_idx;
wcstring username = get_home_directory_name(input, &tail_idx);
-
+
bool tilde_error = false;
wcstring home;
if (username.empty())
@@ -1639,18 +1639,18 @@ static void expand_home_directory(wcstring &input)
home = str2wcstring(userinfo->pw_dir);
}
}
-
- wchar_t *realhome;
- realhome = wrealpath(home, NULL);
-
+
+ wchar_t *realhome = wrealpath(home, NULL);
+
if (! tilde_error && realhome)
{
input.replace(input.begin(), input.begin() + tail_idx, realhome);
}
- else
- {
+ else
+ {
input[0] = L'~';
- }
+ }
+ free((void *)realhome);
}
}