Bug 237573

Summary: Remove invalid ASSERT in LocaleIDBuilder::overrideLanguageScriptRegion().
Product: WebKit Reporter: Mark Lam <mark.lam>
Component: JavaScriptCoreAssignee: Mark Lam <mark.lam>
Status: RESOLVED FIXED    
Severity: Normal CC: ews-watchlist, keith_miller, msaboff, saam, tzagallo, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
proposed patch.
mark.lam: review-
[fast-cq] proposed patch. none

Description Mark Lam 2022-03-07 18:22:44 PST
localeIDBufferForLanguageTagWithNullTerminator() uses uloc_forLanguageTag, and uloc_forLanguageTag can return an empty (0 length) localeID.  LocaleIDBuilder::initialize() uses localeIDBufferForLanguageTagWithNullTerminator() to return a buffer sized based on the localeID it contains.  However, when the localeID is not found, we currently erroneously return a non-empty buffer.  This patch fixes this by adding a length check, and returning an empty buffer if the localeID length is 0.

rdar://83326232
Comment 1 Mark Lam 2022-03-07 18:23:14 PST
<rdar://problem/83326232>
Comment 2 Mark Lam 2022-03-07 18:29:36 PST
Created attachment 454059 [details]
proposed patch.
Comment 3 Yusuke Suzuki 2022-03-07 18:32:59 PST
Comment on attachment 454059 [details]
proposed patch.

r=me
Comment 4 Mark Lam 2022-03-07 19:21:16 PST
Comment on attachment 454059 [details]
proposed patch.

Looks like my fix is wrong.  Will investigate.
Comment 5 Mark Lam 2022-03-07 20:03:29 PST
Turns out the ASSERT(length) in LocaleIDBuilder::overrideLanguageScriptRegion() is simply incorrect.  The length can be 0 if uloc_forLanguageTag returns a 0 length in localeIDBufferForLanguageTagWithNullTerminator().  LocaleIDBuilder::overrideLanguageScriptRegion() already handles this scenario correctly.  We just need to remove this incorrect ASSERT.
Comment 6 Mark Lam 2022-03-07 20:08:36 PST
Created attachment 454064 [details]
[fast-cq] proposed patch.
Comment 7 Yusuke Suzuki 2022-03-07 20:14:42 PST
Comment on attachment 454064 [details]
[fast-cq] proposed patch.

r=me
Comment 8 Mark Lam 2022-03-08 01:07:17 PST
Comment on attachment 454064 [details]
[fast-cq] proposed patch.

Thanks for the review.  Landing now.
Comment 9 EWS 2022-03-08 01:10:35 PST
Committed r290981 (248159@main): <https://commits.webkit.org/248159@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 454064 [details].