1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-02-20 21:26:53 +00:00

fixup! refactor: use cpputf for utf8 validation and conversion (#2251) (#2264)

silence a nullptr-dereference warning
This commit is contained in:
Charles Kerr 2021-12-03 18:07:17 -06:00 committed by GitHub
parent e5e11e3c83
commit cc4cf1da5a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -788,8 +788,11 @@ bool tr_utf8_validate(std::string_view sv, char const** good_end)
static char* strip_non_utf8(std::string_view sv)
{
char* ret = tr_new(char, std::size(sv) + 1);
auto const it = utf8::unchecked::replace_invalid(std::data(sv), std::data(sv) + std::size(sv), ret, '?');
*it = '\0';
if (ret != nullptr)
{
auto const it = utf8::unchecked::replace_invalid(std::data(sv), std::data(sv) + std::size(sv), ret, '?');
*it = '\0';
}
return ret;
}