Bug 303428

Summary: CString.isEmpty() for String.utf8() returns true when String has a single character
Product: WebKit Reporter: ankshit <ankshit_jain>
Component: New BugsAssignee: Xabier Rodríguez Calvar <calvaris>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, calvaris, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 289787    

ankshit
Reported 2025-12-02 15:36:24 PST
CString.isEmpty() for String.utf8() returns true when String has a single character. ``` String s = "a"_s; CString utf8 = s.utf8(); utf8.isEmpty() // true, should be false ```
Attachments
Alex Christensen
Comment 1 2025-12-02 15:42:45 PST
Seems to be broken since https://commits.webkit.org/303011@main We should probably return true if the length is 0 or the length is 1 and the contents are the null terminator character. Right now we don't check for the null terminator.
Xabier Rodríguez Calvar
Comment 2 2025-12-03 01:46:14 PST
EWS
Comment 3 2025-12-03 09:27:47 PST
Committed 303840@main (1c43f6f71325): <https://commits.webkit.org/303840@main> Reviewed commits have been landed. Closing PR #54762 and removing active labels.
Radar WebKit Bug Importer
Comment 4 2025-12-03 09:28:12 PST
Note You need to log in before you can comment on or make changes to this bug.