Commit d2a0284d authored by Kjell Ahlstedt's avatar Kjell Ahlstedt

Merge branch 'plug_ustring_make_valid_leak' into 'master'

Fix memory leak in Glib::ustring::make_valid()

See merge request !11
parents 0e8e956d 5d634e30
...@@ -1221,7 +1221,7 @@ ustring::validate(ustring::const_iterator& first_invalid) const ...@@ -1221,7 +1221,7 @@ ustring::validate(ustring::const_iterator& first_invalid) const
ustring ustring
ustring::make_valid() const ustring::make_valid() const
{ {
return ustring(g_utf8_make_valid(string_.data(), string_.size())); return convert_return_gchar_ptr_to_ustring(g_utf8_make_valid(string_.data(), string_.size()));
} }
bool bool
...@@ -1242,37 +1242,32 @@ ustring::is_ascii() const ...@@ -1242,37 +1242,32 @@ ustring::is_ascii() const
ustring ustring
ustring::normalize(NormalizeMode mode) const ustring::normalize(NormalizeMode mode) const
{ {
const auto buf = make_unique_ptr_gfree( return convert_return_gchar_ptr_to_ustring(
g_utf8_normalize(string_.data(), string_.size(), static_cast<GNormalizeMode>(int(mode)))); g_utf8_normalize(string_.data(), string_.size(), static_cast<GNormalizeMode>(int(mode))));
return ustring(buf.get());
} }
ustring ustring
ustring::uppercase() const ustring::uppercase() const
{ {
const auto buf = make_unique_ptr_gfree(g_utf8_strup(string_.data(), string_.size())); return convert_return_gchar_ptr_to_ustring(g_utf8_strup(string_.data(), string_.size()));
return ustring(buf.get());
} }
ustring ustring
ustring::lowercase() const ustring::lowercase() const
{ {
const auto buf = make_unique_ptr_gfree(g_utf8_strdown(string_.data(), string_.size())); return convert_return_gchar_ptr_to_ustring(g_utf8_strdown(string_.data(), string_.size()));
return ustring(buf.get());
} }
ustring ustring
ustring::casefold() const ustring::casefold() const
{ {
const auto buf = make_unique_ptr_gfree(g_utf8_casefold(string_.data(), string_.size())); return convert_return_gchar_ptr_to_ustring(g_utf8_casefold(string_.data(), string_.size()));
return ustring(buf.get());
} }
std::string std::string
ustring::collate_key() const ustring::collate_key() const
{ {
const auto buf = make_unique_ptr_gfree(g_utf8_collate_key(string_.data(), string_.size())); return convert_return_gchar_ptr_to_stdstring(g_utf8_collate_key(string_.data(), string_.size()));
return std::string(buf.get());
} }
std::string std::string
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment