diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2024-10-07 20:44:50 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-10-08 08:21:24 +0200 |
commit | 61e569c5fc96919b5a6bc0ead2477ca3eb6b792c (patch) | |
tree | 6c9b2973f3cbd96b2c85d8042da9d98c17310197 /i18npool/source/search | |
parent | 9c9d2e21be06fa1c806c110812d6df783109d8b9 (diff) |
cid#1607401 Data race condition
coverity seems to be having trouble seeing through the function
pointers
and
cid#1607619 Data race condition
Change-Id: I94692f124dd82b58be6aee41b49cb309f66b213d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174641
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'i18npool/source/search')
-rw-r--r-- | i18npool/source/search/textsearch.cxx | 28 | ||||
-rw-r--r-- | i18npool/source/search/textsearch.hxx | 18 |
2 files changed, 23 insertions, 23 deletions
diff --git a/i18npool/source/search/textsearch.cxx b/i18npool/source/search/textsearch.cxx index dbb49f494781..5475ef5b7dde 100644 --- a/i18npool/source/search/textsearch.cxx +++ b/i18npool/source/search/textsearch.cxx @@ -374,7 +374,7 @@ SearchResult TextSearch::searchForward( const OUString& searchStr, sal_Int32 sta ? FindPosInSeq_Impl( offset, endPos ) : in_str.getLength(); - sres = (this->*fnForward)( in_str, newStartPos, newEndPos ); + sres = (this->*fnForward)( g, in_str, newStartPos, newEndPos ); // Map offsets back to untransliterated string. const sal_Int32 nOffsets = offset.getLength(); @@ -412,7 +412,7 @@ SearchResult TextSearch::searchForward( const OUString& searchStr, sal_Int32 sta if ( bReplaceApostrophe ) in_str = in_str.replace(u'\u2019', '\''); - sres = (this->*fnForward)( in_str, startPos, endPos ); + sres = (this->*fnForward)( g, in_str, startPos, endPos ); } if ( xTranslit2.is() && aSrchPara.AlgorithmType2 != SearchAlgorithms2::REGEXP) @@ -433,7 +433,7 @@ SearchResult TextSearch::searchForward( const OUString& searchStr, sal_Int32 sta endPos = in_str.getLength(); bUsePrimarySrchStr = false; - sres2 = (this->*fnForward)( in_str, startPos, endPos ); + sres2 = (this->*fnForward)( g, in_str, startPos, endPos ); auto sres2_startOffsetRange = asNonConstRange(sres2.startOffset); auto sres2_endOffsetRange = asNonConstRange(sres2.endOffset); @@ -496,7 +496,7 @@ SearchResult TextSearch::searchBackward( const OUString& searchStr, sal_Int32 st // if (pRegexMatcher && startPos < searchStr.getLength()) // but that appears to be impossible with ICU regex - sres = (this->*fnBackward)( in_str, newStartPos, newEndPos ); + sres = (this->*fnBackward)( g, in_str, newStartPos, newEndPos ); // Map offsets back to untransliterated string. const sal_Int32 nOffsets = offset.getLength(); @@ -534,7 +534,7 @@ SearchResult TextSearch::searchBackward( const OUString& searchStr, sal_Int32 st if ( bReplaceApostrophe ) in_str = replacePunctuation(in_str); - sres = (this->*fnBackward)( in_str, startPos, endPos ); + sres = (this->*fnBackward)( g, in_str, startPos, endPos ); } if ( xTranslit2.is() && aSrchPara.AlgorithmType2 != SearchAlgorithms2::REGEXP ) @@ -555,7 +555,7 @@ SearchResult TextSearch::searchBackward( const OUString& searchStr, sal_Int32 st endPos = FindPosInSeq_Impl( offset, endPos ); bUsePrimarySrchStr = false; - sres2 = (this->*fnBackward)( in_str, startPos, endPos ); + sres2 = (this->*fnBackward)( g, in_str, startPos, endPos ); auto sres2_startOffsetRange = asNonConstRange(sres2.startOffset); auto sres2_endOffsetRange = asNonConstRange(sres2.endOffset); @@ -720,7 +720,7 @@ sal_Int32 TextSearch::GetDiff( const sal_Unicode cChr ) const } -SearchResult TextSearch::NSrchFrwrd( const OUString& searchStr, sal_Int32 startPos, sal_Int32 endPos ) +SearchResult TextSearch::NSrchFrwrd( std::unique_lock<std::mutex>& /*rGuard*/, const OUString& searchStr, sal_Int32 startPos, sal_Int32 endPos ) { SearchResult aRet; aRet.subRegExpressions = 0; @@ -783,7 +783,7 @@ SearchResult TextSearch::NSrchFrwrd( const OUString& searchStr, sal_Int32 startP return aRet; } -SearchResult TextSearch::NSrchBkwrd( const OUString& searchStr, sal_Int32 startPos, sal_Int32 endPos ) +SearchResult TextSearch::NSrchBkwrd( std::unique_lock<std::mutex>& /*rGuard*/,const OUString& searchStr, sal_Int32 startPos, sal_Int32 endPos ) { SearchResult aRet; aRet.subRegExpressions = 0; @@ -943,7 +943,7 @@ static bool lcl_findRegex(std::unique_ptr<icu::RegexMatcher> const& pRegexMatche return true; } -SearchResult TextSearch::RESrchFrwrd( const OUString& searchStr, +SearchResult TextSearch::RESrchFrwrd( std::unique_lock<std::mutex>& /*rGuard*/, const OUString& searchStr, sal_Int32 startPos, sal_Int32 endPos ) { SearchResult aRet; @@ -997,7 +997,7 @@ SearchResult TextSearch::RESrchFrwrd( const OUString& searchStr, return aRet; } -SearchResult TextSearch::RESrchBkwrd( const OUString& searchStr, +SearchResult TextSearch::RESrchBkwrd( std::unique_lock<std::mutex>& /*rGuard*/, const OUString& searchStr, sal_Int32 startPos, sal_Int32 endPos ) { // NOTE: for backwards search callers provide startPos/endPos inverted! @@ -1072,7 +1072,7 @@ SearchResult TextSearch::RESrchBkwrd( const OUString& searchStr, // search for words phonetically -SearchResult TextSearch::ApproxSrchFrwrd( const OUString& searchStr, +SearchResult TextSearch::ApproxSrchFrwrd( std::unique_lock<std::mutex>& /*rGuard*/, const OUString& searchStr, sal_Int32 startPos, sal_Int32 endPos ) { SearchResult aRet; @@ -1114,7 +1114,7 @@ SearchResult TextSearch::ApproxSrchFrwrd( const OUString& searchStr, return aRet; } -SearchResult TextSearch::ApproxSrchBkwrd( const OUString& searchStr, +SearchResult TextSearch::ApproxSrchBkwrd( std::unique_lock<std::mutex>& /*rGuard*/, const OUString& searchStr, sal_Int32 startPos, sal_Int32 endPos ) { SearchResult aRet; @@ -1163,7 +1163,7 @@ void setWildcardMatch( css::util::SearchResult& rRes, sal_Int32 nStartOffset, sa } } -SearchResult TextSearch::WildcardSrchFrwrd( const OUString& searchStr, sal_Int32 nStartPos, sal_Int32 nEndPos ) +SearchResult TextSearch::WildcardSrchFrwrd( std::unique_lock<std::mutex>& /*rGuard*/, const OUString& searchStr, sal_Int32 nStartPos, sal_Int32 nEndPos ) { SearchResult aRes; aRes.subRegExpressions = 0; // no match @@ -1334,7 +1334,7 @@ SearchResult TextSearch::WildcardSrchFrwrd( const OUString& searchStr, sal_Int32 return aRes; } -SearchResult TextSearch::WildcardSrchBkwrd( const OUString& searchStr, sal_Int32 nStartPos, sal_Int32 nEndPos ) +SearchResult TextSearch::WildcardSrchBkwrd( std::unique_lock<std::mutex>& /*rGuard*/, const OUString& searchStr, sal_Int32 nStartPos, sal_Int32 nEndPos ) { SearchResult aRes; aRes.subRegExpressions = 0; // no match diff --git a/i18npool/source/search/textsearch.hxx b/i18npool/source/search/textsearch.hxx index 9fda11751d83..67ba1f50a320 100644 --- a/i18npool/source/search/textsearch.hxx +++ b/i18npool/source/search/textsearch.hxx @@ -60,7 +60,7 @@ class TextSearch: public cppu::WeakImplHelper // define a function pointer for the different search methods typedef css::util::SearchResult - (TextSearch::*FnSrch)( const OUString& searchStr, + (TextSearch::*FnSrch)( std::unique_lock<std::mutex>& rGuard, const OUString& searchStr, sal_Int32 startPos, sal_Int32 endPos ); FnSrch fnForward; @@ -81,22 +81,22 @@ class TextSearch: public cppu::WeakImplHelper sal_Int32 GetDiff( const sal_Unicode ) const; /// @throws css::uno::RuntimeException css::util::SearchResult - NSrchFrwrd( const OUString& searchStr, + NSrchFrwrd( std::unique_lock<std::mutex>& rGuard, const OUString& searchStr, sal_Int32 startPos, sal_Int32 endPos ); /// @throws css::uno::RuntimeException css::util::SearchResult - NSrchBkwrd( const OUString& searchStr, + NSrchBkwrd( std::unique_lock<std::mutex>& rGuard, const OUString& searchStr, sal_Int32 startPos, sal_Int32 endPos ); // Members and methods for the regular expression search std::unique_ptr<icu::RegexMatcher> pRegexMatcher; /// @throws css::uno::RuntimeException css::util::SearchResult - RESrchFrwrd( const OUString& searchStr, + RESrchFrwrd( std::unique_lock<std::mutex>& rGuard, const OUString& searchStr, sal_Int32 startPos, sal_Int32 endPos ); /// @throws css::uno::RuntimeException css::util::SearchResult - RESrchBkwrd( const OUString& searchStr, + RESrchBkwrd( std::unique_lock<std::mutex>& rGuard, const OUString& searchStr, sal_Int32 startPos, sal_Int32 endPos ); void RESrchPrepare( const css::util::SearchOptions2&); @@ -106,11 +106,11 @@ class TextSearch: public cppu::WeakImplHelper css::uno::Reference < css::i18n::XBreakIterator > xBreak; /// @throws css::uno::RuntimeException css::util::SearchResult - ApproxSrchFrwrd( const OUString& searchStr, + ApproxSrchFrwrd( std::unique_lock<std::mutex>& rGuard, const OUString& searchStr, sal_Int32 startPos, sal_Int32 endPos ); /// @throws css::uno::RuntimeException css::util::SearchResult - ApproxSrchBkwrd( const OUString& searchStr, + ApproxSrchBkwrd( std::unique_lock<std::mutex>& rGuard, const OUString& searchStr, sal_Int32 startPos, sal_Int32 endPos ); // Members and methods for the wildcard search @@ -120,11 +120,11 @@ class TextSearch: public cppu::WeakImplHelper bool mbWildcardAllowSubstring; /// @throws css::uno::RuntimeException css::util::SearchResult - WildcardSrchFrwrd( const OUString& searchStr, + WildcardSrchFrwrd( std::unique_lock<std::mutex>& rGuard, const OUString& searchStr, sal_Int32 startPos, sal_Int32 endPos ); /// @throws css::uno::RuntimeException css::util::SearchResult - WildcardSrchBkwrd( const OUString& searchStr, + WildcardSrchBkwrd( std::unique_lock<std::mutex>& rGuard, const OUString& searchStr, sal_Int32 startPos, sal_Int32 endPos ); bool IsDelimiter( const OUString& rStr, sal_Int32 nPos ) const; |