Bug 1880996 - Check for zero-length text in nsBidiPresUtils::ProcessSimpleRun. r=dholbert

In the example here, failing to check for an empty string was resulting
in lots of extra work to set up for drawing a shadow, etc., even though
nothing ends up being rendered. Just bail out early if there's no text.

Differential Revision: https://phabricator.services.mozilla.com/D202630
This commit is contained in:
Jonathan Kew 2024-02-24 08:56:43 +00:00
Родитель afaa047fb9
Коммит b6a960c96c
1 изменённых файлов: 6 добавлений и 0 удалений

Просмотреть файл

@ -2363,6 +2363,12 @@ void nsBidiPresUtils::ProcessSimpleRun(const char16_t* aText, size_t aLength,
nsBidiPositionResolve* aPosResolve,
int32_t aPosResolveCount,
nscoord* aWidth) {
if (!aLength) {
if (aWidth) {
*aWidth = 0;
}
return;
}
// Get bidi class from the first (or only) character.
uint32_t ch = aText[0];
if (aLength > 1 && NS_IS_HIGH_SURROGATE(ch) &&