Bug 1468131 - Avoid a ubsan complaint in GetTrimmableWhitespaceCount r=emilio

ubsan was complaining about the expression
```
    const char* str = aFrag->Get1b() + aStartOffset;
```
when `aFrag->Get1b() == nullptr` and `aStartOffset == -1`, because the addition generates an invalid pointer.

Due to other logic in the function, we would never dereference that pointer, so it was reasonably harmless, but this patch silences the complaint.

Differential Revision: https://phabricator.services.mozilla.com/D49345

--HG--
extra : moz-landing-system : lando
This commit is contained in:
David Major 2019-10-15 22:59:51 +00:00
Родитель dcfbcb56d7
Коммит 2bf032d442
1 изменённых файлов: 4 добавлений и 0 удалений

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

@ -832,6 +832,10 @@ static uint32_t GetTrimmableWhitespaceCount(const nsTextFragment* aFrag,
int32_t aStartOffset,
int32_t aLength,
int32_t aDirection) {
if (!aLength) {
return 0;
}
int32_t count = 0;
if (aFrag->Is2b()) {
const char16_t* str = aFrag->Get2b() + aStartOffset;