Bug 165630

Summary: Add 64-bit signed LEB decode method
Product: WebKit Reporter: Keith Miller <keith_miller>
Component: New BugsAssignee: Keith Miller <keith_miller>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, cdumez, cmarcelo, commit-queue, dbates
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch rniwa: review+

Keith Miller
Reported 2016-12-08 15:24:01 PST
Add 64-bit signed LEB decode method
Attachments
Patch (19.67 KB, patch)
2016-12-08 15:26 PST, Keith Miller
no flags
Patch (20.02 KB, patch)
2016-12-08 16:45 PST, Keith Miller
rniwa: review+
Keith Miller
Comment 1 2016-12-08 15:26:22 PST
Keith Miller
Comment 2 2016-12-08 16:45:45 PST
Ryosuke Niwa
Comment 3 2016-12-08 16:51:33 PST
Comment on attachment 296576 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=296576&action=review > Source/WTF/wtf/LEBDecoder.h:59 > +template<size_t maxByteLength, typename T> > +inline bool WARN_UNUSED_RETURN decodeInt(const uint8_t* bytes, size_t length, size_t& offset, T& result) I think it would have been better maxByteLength was obtained via traits on T. e.g. template <typename T> struct maxLEBBytes; template <> maxLEBBytes<uint32_t> struct { static size_t maxByteLength = 5; } template <> maxLEBBytes<unit64_t> struct { static size_t maxByteLength = 10; } This would be less error prone than passing in matching template arguments. > Source/WTF/wtf/LEBDecoder.h:65 > - size_t last = std::min(max32BitLEBByteLength, length - offset - 1); > + size_t last = std::min(maxByteLength, length - offset) - 1; You should mention -1 moving out of std::min in the change log.
Ryosuke Niwa
Comment 4 2016-12-08 16:52:02 PST
Comment on attachment 296591 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=296591&action=review > Source/WTF/wtf/LEBDecoder.h:41 > + const size_t maxByteLength = (numBits - 1) / 7 + 1; // numBits / 7 rounding up. Nice!
Keith Miller
Comment 5 2016-12-08 17:34:35 PST
Note You need to log in before you can comment on or make changes to this bug.