| Summary: | [WTF] Undefined behavior warning in StringBuilder::allocateBuffer | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Lauro Moura <lmoura> | ||||||
| Component: | Web Template Framework | Assignee: | Lauro Moura <lmoura> | ||||||
| Status: | RESOLVED FIXED | ||||||||
| Severity: | Normal | CC: | aperez, benjamin, bugs-noreply, cdumez, cmarcelo, darin, ews-watchlist, webkit-bug-importer | ||||||
| Priority: | P2 | Keywords: | InRadar | ||||||
| Version: | WebKit Nightly Build | ||||||||
| Hardware: | Unspecified | ||||||||
| OS: | Unspecified | ||||||||
| Attachments: |
|
||||||||
|
Description
Lauro Moura
2021-04-22 12:49:28 PDT
Created attachment 426843 [details]
Patch
Comment on attachment 426843 [details]
Patch
r=me
Comment on attachment 426843 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=426843&action=review > Source/WTF/wtf/text/StringBuilder.cpp:118 > + auto length = m_length.unsafeGet(); > + if (length) > + std::memcpy(m_bufferCharacters8, currentCharacters, length); OK as is, but can be done without the local variable: if (m_length) std::memcpy(m_bufferCharacters8, currentCharacters, m_length.unsafeGet()); If you really like the local, slightly nicer if it’s scoped: if (auto length = m_length.unsafeGet()) std::memcpy(m_bufferCharacters8, currentCharacters, length); Created attachment 426886 [details]
Patch for landing
Committed r276485 (236944@main): <https://commits.webkit.org/236944@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 426886 [details]. |