Make escape() return a wcstring

This avoids the potential for leaking the resulting string.
This commit is contained in:
Kevin Ballard
2014-09-25 18:20:03 -07:00
parent cd4fa518b8
commit 35595dbffd
7 changed files with 23 additions and 33 deletions

View File

@@ -1120,7 +1120,7 @@ static void escape_string_internal(const wchar_t *orig_in, size_t in_len, wcstri
}
}
wchar_t *escape(const wchar_t *in, escape_flags_t flags)
wcstring escape(const wchar_t *in, escape_flags_t flags)
{
if (!in)
{
@@ -1128,9 +1128,9 @@ wchar_t *escape(const wchar_t *in, escape_flags_t flags)
FATAL_EXIT();
}
wcstring tmp;
escape_string_internal(in, wcslen(in), &tmp, flags);
return wcsdup(tmp.c_str());
wcstring result;
escape_string_internal(in, wcslen(in), &result, flags);
return result;
}
wcstring escape_string(const wcstring &in, escape_flags_t flags)