aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvmordovin <vmordovin@yandex-team.com>2023-10-20 22:23:34 +0300
committervmordovin <vmordovin@yandex-team.com>2023-10-20 22:42:43 +0300
commitfd7709f6311e96568ae3b25b1d2ce4bcc7322243 (patch)
tree8888b59c15a95513f62edd43f2aafb500911a306
parent7c2636d1465928546937a5257ca148514773d8ca (diff)
downloadydb-fd7709f6311e96568ae3b25b1d2ce4bcc7322243.tar.gz
[library] Fix ub-sanitizer error 'applying non-zero offset to null pointer'
``` #0 0x23d0d55b in GetSchemePrefixSize(TBasicStringBuf<char, std::__y1::char_traits<char> >) /home/vmordovin/src/arcadia/fuse/arcadia/library/cpp/string_utils/url/url.cpp:111:11 #1 0x23d0ce99 in GetSchemeHostAndPort(TBasicStringBuf<char, std::__y1::char_traits<char> >, bool, bool) /home/vmordovin/src/arcadia/fuse/arcadia/library/cpp/string_utils/url/url.cpp:173:31 #2 0x23d0da8b in NUrl::SplitUrlToHostAndPath(TBasicStringBuf<char, std::__y1::char_traits<char> >) /home/vmordovin/src/arcadia/fuse/arcadia/library/cpp/string_utils/url/url.cpp:68:27 #3 0x23d0da8b in SplitUrlToHostAndPath(TBasicStringBuf<char, std::__y1::char_traits<char> >, TBasicStringBuf<char, std::__y1::char_traits<char> >&, TBasicStringBuf<char, std::__y1::char_traits<char> >&) /hom e/vmordovin/src/arcadia/fuse/arcadia/library/cpp/string_utils/url/url.cpp:201:31 #4 0x2c0d8715 in NReportSnippets::SplitGreenUrl(NSc::TValue&, TBasicStringBuf<char, std::__y1::char_traits<char> >, TBasicStringBuf<char, std::__y1::char_traits<char> >) /home/vmordovin/src/arcadia/fuse/arca dia/search/web/util/report_snippets/report_snippets.cpp:50:5 #5 0x2363d63b in (anonymous namespace)::TReportSnippetGenericContext::ProcessGrouping(TMetaGrouping&, TGroupingIndex const&, IMetaRearrangeContext::TRearrangeParams const&) /home/vmordovin/src/arcadia/fuse/a rcadia/search/web/rearrange/rep_snip_generic/generic.cpp:129:21 ... ```
-rw-r--r--library/cpp/string_utils/url/url.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/library/cpp/string_utils/url/url.cpp b/library/cpp/string_utils/url/url.cpp
index 44e6cb671a..c850afa5a7 100644
--- a/library/cpp/string_utils/url/url.cpp
+++ b/library/cpp/string_utils/url/url.cpp
@@ -98,6 +98,10 @@ TWtringBuf CutHttpPrefix(const TWtringBuf url, bool ignorehttps) noexcept {
}
size_t GetSchemePrefixSize(const TStringBuf url) noexcept {
+ if (url.empty()) {
+ return 0;
+ }
+
struct TDelim: public str_spn {
inline TDelim()
: str_spn("!-/:-@[-`{|}", true)
@@ -433,4 +437,3 @@ bool DoesUrlPathStartWithToken(TStringBuf url, const TStringBuf& token) noexcept
const bool prefixIsToken = slashAfterPrefix || qMarkAfterPrefix || nothingAfterPrefix;
return prefixIsToken;
}
-