summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/svtools/svparser.hxx1
-rw-r--r--svtools/source/svrtf/svparser.cxx11
2 files changed, 11 insertions, 1 deletions
diff --git a/include/svtools/svparser.hxx b/include/svtools/svparser.hxx
index e1a74840add0..1b9431a69ee6 100644
--- a/include/svtools/svparser.hxx
+++ b/include/svtools/svparser.hxx
@@ -51,6 +51,7 @@ protected:
OUStringBuffer aToken; // scanned token
sal_uInt32 nlLineNr; // current line number
sal_uInt32 nlLinePos; // current column number
+ sal_uInt32 nConversionErrors; // count of conversion errors
std::unique_ptr<SvParser_Impl<T>> pImplData; // internal data
tools::Long m_nTokenIndex; // current token index to detect loops for seeking backwards
diff --git a/svtools/source/svrtf/svparser.cxx b/svtools/source/svrtf/svparser.cxx
index 1a8e73d0edb6..c003bcae21a9 100644
--- a/svtools/source/svrtf/svparser.cxx
+++ b/svtools/source/svrtf/svparser.cxx
@@ -78,6 +78,7 @@ SvParser<T>::SvParser( SvStream& rIn, sal_uInt8 nStackSize )
: rInput( rIn )
, nlLineNr( 1 )
, nlLinePos( 1 )
+ , nConversionErrors( 0 )
, pImplData( nullptr )
, m_nTokenIndex(0)
, nTokenValue( 0 )
@@ -338,6 +339,7 @@ sal_uInt32 SvParser<T>::GetNextChar()
// do
c = '?';
nChars = 1;
+ ++nConversionErrors;
}
}
}
@@ -384,6 +386,7 @@ sal_uInt32 SvParser<T>::GetNextChar()
c = reinterpret_cast<unsigned char&>( sBuffer[0] );
rInput.SeekRel( -(nLen-1) );
nChars = 1;
+ ++nConversionErrors;
}
}
}
@@ -405,7 +408,7 @@ sal_uInt32 SvParser<T>::GetNextChar()
// because a conversion is not available, do no conversion at all.
c = reinterpret_cast<unsigned char&>( c1 );
nChars = 1;
-
+ ++nConversionErrors;
}
}
}
@@ -416,6 +419,12 @@ sal_uInt32 SvParser<T>::GetNextChar()
if ( ! rtl::isUnicodeScalarValue( c ) )
c = '?' ;
+ if (bFuzzing && nConversionErrors > 128)
+ {
+ SAL_WARN("svtools", "SvParser::GetNextChar too many conversion errors while fuzzing, abandoning for performance");
+ bErr = true;
+ }
+
if( bErr )
{
if( ERRCODE_IO_PENDING == rInput.GetError() )