[Webkit-unassigned] [Bug 231606] ASSERT hit in surrogatePairAwareIndex and surrogatePairAwareStart lambdas for text with unpaired surrogates

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Oct 12 17:50:54 PDT 2021


https://bugs.webkit.org/show_bug.cgi?id=231606

--- Comment #14 from Darin Adler <darin at apple.com> ---
Comment on attachment 440982
  --> https://bugs.webkit.org/attachment.cgi?id=440982
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=440982&action=review

>>> Source/WebCore/layout/formattingContexts/inline/text/TextUtil.cpp:155
>>>  
>> 
>> It would be:
>> 
>>     auto right = std::min<unsigned>(left + offset, (startPosition + length - 1));
>>     U16_SET_CP_LIMIT(text, 0, right, text.length());
>> 
>>     auto middle = surrogatePairAwareIndex((left + right) / 2);
>>     U16_SET_CP_LIMIT(text, 0, middle, text.length());
> 
> Thank you, I will try this! Although I just notice that currently, surrogatePairAwareIndex returns the index at trail whereas U16_SET_CP_LIMIT returns the index past it:
> 
> #define U16_SET_CP_LIMIT(s, start, i, length) UPRV_BLOCK_MACRO_BEGIN { \
>     if((start)<(i) && ((i)<(length) || (length)<0) && U16_IS_LEAD((s)[(i)-1]) && U16_IS_TRAIL((s)[i])) { \
>         ++(i); \
>     } \
> } UPRV_BLOCK_MACRO_END

Oh, OK, good point. So my code is wrong. It would be more like this:

    auto right = std::min<unsigned>(left + offset + 1, startPosition + length);
    U16_SET_CP_LIMIT(text, 0, right, text.length());
    --right;

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20211013/0118f191/attachment.htm>


More information about the webkit-unassigned mailing list