Skip to content
Permalink
Browse files
ASSERT(status == U_ZERO_ERROR) under SearchBuffer::search() when typi…
…ng in the url bar in the iOS simulator

https://bugs.webkit.org/show_bug.cgi?id=240699
<rdar://92182174>

Reviewed by Tim Horton.

Replace `status == U_ZERO_ERROR` tests with `U_SUCCESS(status)`.

* Source/WebCore/PAL/pal/text/TextCodecICU.cpp:
(PAL::ErrorCallbackSetter::ErrorCallbackSetter):
(PAL::ErrorCallbackSetter::~ErrorCallbackSetter):
* Source/WebKit/UIProcess/Cocoa/ModalContainerControlClassifier.mm:
(WebKit::SpoofChecker::checker):
* Source/WebCore/editing/TextIterator.cpp:
(WebCore::createSearcher):
(WebCore::SearchBuffer::SearchBuffer):
(WebCore::SearchBuffer::~SearchBuffer):
(WebCore::SearchBuffer::search):

Canonical link: https://commits.webkit.org/250786@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294531 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
smfr committed May 20, 2022
1 parent b3dedd0 commit a4adc3e8a686affb28e8429cf059af448502bb32
Showing 3 changed files with 11 additions and 11 deletions.
@@ -208,7 +208,7 @@ class ErrorCallbackSetter {
if (m_shouldStopOnEncodingErrors) {
UErrorCode err = U_ZERO_ERROR;
ucnv_setToUCallBack(&m_converter, UCNV_TO_U_CALLBACK_SUBSTITUTE, UCNV_SUB_STOP_ON_ILLEGAL, &m_savedAction, &m_savedContext, &err);
ASSERT(err == U_ZERO_ERROR);
ASSERT(U_SUCCESS(err));
}
}
~ErrorCallbackSetter()
@@ -220,7 +220,7 @@ class ErrorCallbackSetter {
ucnv_setToUCallBack(&m_converter, m_savedAction, m_savedContext, &oldAction, &oldContext, &err);
ASSERT(oldAction == UCNV_TO_U_CALLBACK_SUBSTITUTE);
ASSERT(!strcmp(static_cast<const char*>(oldContext), UCNV_SUB_STOP_ON_ILLEGAL));
ASSERT(err == U_ZERO_ERROR);
ASSERT(U_SUCCESS(err));
}
}

@@ -1658,7 +1658,7 @@ static UStringSearch* createSearcher()
UErrorCode status = U_ZERO_ERROR;
auto searchCollatorName = makeString(currentSearchLocaleID(), "@collation=search");
UStringSearch* searcher = usearch_open(&newlineCharacter, 1, &newlineCharacter, 1, searchCollatorName.utf8().data(), 0, &status);
ASSERT(status == U_ZERO_ERROR || status == U_USING_FALLBACK_WARNING || status == U_USING_DEFAULT_WARNING);
ASSERT(U_SUCCESS(status) || status == U_USING_FALLBACK_WARNING || status == U_USING_DEFAULT_WARNING);
return searcher;
}

@@ -1965,10 +1965,10 @@ inline SearchBuffer::SearchBuffer(const String& target, FindOptions options)

UErrorCode status = U_ZERO_ERROR;
usearch_setAttribute(searcher, USEARCH_ELEMENT_COMPARISON, comparator, &status);
ASSERT(status == U_ZERO_ERROR);
ASSERT(U_SUCCESS(status));

usearch_setPattern(searcher, m_targetCharacters, targetLength, &status);
ASSERT(status == U_ZERO_ERROR);
ASSERT(U_SUCCESS(status));

// The kana workaround requires a normalized copy of the target string.
if (m_targetRequiresKanaWorkaround)
@@ -1980,9 +1980,9 @@ inline SearchBuffer::~SearchBuffer()
// Leave the static object pointing to a valid string.
UErrorCode status = U_ZERO_ERROR;
usearch_setPattern(WebCore::searcher(), &newlineCharacter, 1, &status);
ASSERT(status == U_ZERO_ERROR);
ASSERT(U_SUCCESS(status));
usearch_setText(WebCore::searcher(), &newlineCharacter, 1, &status);
ASSERT(status == U_ZERO_ERROR);
ASSERT(U_SUCCESS(status));

unlockSearcher();
}
@@ -2190,10 +2190,10 @@ inline size_t SearchBuffer::search(size_t& start)

UErrorCode status = U_ZERO_ERROR;
usearch_setText(searcher, m_buffer.data(), size, &status);
ASSERT(status == U_ZERO_ERROR);
ASSERT(U_SUCCESS(status));

usearch_setOffset(searcher, m_prefixLength, &status);
ASSERT(status == U_ZERO_ERROR);
ASSERT(U_SUCCESS(status));

int matchStart = usearch_next(searcher, &status);
ASSERT(U_SUCCESS(status));
@@ -2231,7 +2231,7 @@ inline size_t SearchBuffer::search(size_t& start)
|| (m_options.contains(AtWordStarts) && !isWordStartMatch(matchStart, matchedLength))
|| (m_options.contains(AtWordEnds) && !isWordEndMatch(matchStart, matchedLength))) {
matchStart = usearch_next(searcher, &status);
ASSERT(status == U_ZERO_ERROR);
ASSERT(U_SUCCESS(status));
goto nextMatch;
}

@@ -99,7 +99,7 @@ bool areConfusable(NSString *potentialSpoofString, const char* stringToSpoof)
private:
USpoofChecker* checker()
{
if (!m_checker && m_status == U_ZERO_ERROR)
if (!m_checker && U_SUCCESS(m_status))
m_checker = uspoof_open(&m_status);
return m_checker;
}

0 comments on commit a4adc3e

Please sign in to comment.