| Summary: | Fix size computation in WebCore::StorageMap | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Sihui Liu <sihui_liu> | ||||||||
| Component: | Website Storage | Assignee: | Sihui Liu <sihui_liu> | ||||||||
| Status: | RESOLVED FIXED | ||||||||||
| Severity: | Normal | CC: | achristensen, cdumez, sihui_liu, webkit-bug-importer | ||||||||
| Priority: | P2 | Keywords: | InRadar | ||||||||
| Version: | WebKit Nightly Build | ||||||||||
| Hardware: | Unspecified | ||||||||||
| OS: | Unspecified | ||||||||||
| Attachments: |
|
||||||||||
|
Description
Sihui Liu
2022-04-08 22:01:19 PDT
Created attachment 457147 [details]
Patch
Comment on attachment 457147 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=457147&action=review r=me > Source/WebCore/storage/StorageMap.cpp:167 > + for (auto& pair : m_impl->map) Why not use `for (auto& [key, value] : m_impl->map) {` like you did below? > Source/WebCore/storage/StorageMap.cpp:168 > + newSize += (pair.key.sizeInBytes() + pair.value.sizeInBytes()); Might need to be written like so for overflow checks: newSize += (pair.key.sizeInBytes(); newSize += pair.value.sizeInBytes()); Otherwise, there might be an issue if `pair.key.sizeInBytes() + pair.value.sizeInBytes()` overflows, no? > Source/WebCore/storage/StorageMap.cpp:174 > + newSize += key.sizeInBytes() + value.sizeInBytes(); Same comment as above about overflows. Created attachment 457270 [details]
Patch for landing
(In reply to Chris Dumez from comment #3) > Comment on attachment 457147 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=457147&action=review > > r=me > > > Source/WebCore/storage/StorageMap.cpp:167 > > + for (auto& pair : m_impl->map) > > Why not use `for (auto& [key, value] : m_impl->map) {` like you did below? Updated. > > > Source/WebCore/storage/StorageMap.cpp:168 > > + newSize += (pair.key.sizeInBytes() + pair.value.sizeInBytes()); > > Might need to be written like so for overflow checks: > newSize += (pair.key.sizeInBytes(); > newSize += pair.value.sizeInBytes()); > > Otherwise, there might be an issue if `pair.key.sizeInBytes() + > pair.value.sizeInBytes()` overflows, no? Yes, updated. > > > Source/WebCore/storage/StorageMap.cpp:174 > > + newSize += key.sizeInBytes() + value.sizeInBytes(); > > Same comment as above about overflows. Updated. Created attachment 457273 [details]
Patch for landing
Patch 457270 does not build Committed r292721 (249507@main): <https://commits.webkit.org/249507@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 457273 [details]. |