Summary: | [Content Extensions] Use less memory when writing byte code to file | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Alex Christensen <achristensen> | ||||||
Component: | WebCore Misc. | Assignee: | Alex Christensen <achristensen> | ||||||
Status: | RESOLVED FIXED | ||||||||
Severity: | Normal | ||||||||
Priority: | P2 | ||||||||
Version: | 528+ (Nightly build) | ||||||||
Hardware: | Unspecified | ||||||||
OS: | Unspecified | ||||||||
Attachments: |
|
Description
Alex Christensen
2015-05-04 15:55:20 PDT
Created attachment 252343 [details]
Patch
Comment on attachment 252343 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=252343&action=review > Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.cpp:77 > +const size_t ContentExtensionFileHeaderSize = sizeof(uint32_t) + 2 * sizeof(uint64_t); Why do this instead of sizeof(ContentExtensionMetaData)? Because of alignment, I suspect the expression above will be wrong. Comment on attachment 252343 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=252343&action=review >> Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.cpp:77 >> +const size_t ContentExtensionFileHeaderSize = sizeof(uint32_t) + 2 * sizeof(uint64_t); > > Why do this instead of sizeof(ContentExtensionMetaData)? Because of alignment, I suspect the expression above will be wrong. When writing the header, we only want to write 20 bytes. Otherwise we would be writing uninitialized memory to file. Created attachment 252355 [details]
Patch
Comment on attachment 252355 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=252355&action=review > Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.cpp:84 > static Data encodeContentExtensionMetaData(const ContentExtensionMetaData& metaData) I think you want to add this to the end of this function: ASSERT(encoder.bufferSize() == ContentExtensionFileHeaderSize); > Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.cpp:218 > + memset(invalidHeader, 0xff, sizeof(invalidHeader)); We normally use capitalized hex, 0xFF, in WebKit code. |