aboutsummaryrefslogtreecommitdiffhomepage
path: root/common.cpp
diff options
context:
space:
mode:
authorGravatar Kevin Ballard <kevin@sb.org>2014-09-25 18:20:03 -0700
committerGravatar Kevin Ballard <kevin@sb.org>2014-09-25 18:20:03 -0700
commit35595dbffdf413694b31da46129432ef345921af (patch)
treee78b379cf7854b1a8402f8da267e8f6d84450c6f /common.cpp
parentcd4fa518b86ddfb3e946fa4dd69e9e32a58ef81e (diff)
Make escape() return a wcstring
This avoids the potential for leaking the resulting string.
Diffstat (limited to 'common.cpp')
-rw-r--r--common.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/common.cpp b/common.cpp
index 7429fcbe..825d2501 100644
--- a/common.cpp
+++ b/common.cpp
@@ -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)