mirror of
https://github.com/foliojs/pdfkit.git
synced 2025-12-08 20:15:54 +00:00
Fix reading UInt32
In JS, 0x80 << 24 yields a negative result. Also, 0x80000000|0 < 0. Bitwise ops should be avoided for very long unsigned ints.
This commit is contained in:
parent
26a0753d6c
commit
b60fe860e0
@ -19,11 +19,11 @@ class Data
|
||||
@writeByte if val then 1 else 0
|
||||
|
||||
readUInt32: ->
|
||||
b1 = @readByte() << 24
|
||||
b1 = @readByte() * 0x1000000
|
||||
b2 = @readByte() << 16
|
||||
b3 = @readByte() << 8
|
||||
b4 = @readByte()
|
||||
b1 | b2 | b3 | b4
|
||||
b1 + b2 + b3 + b4
|
||||
|
||||
writeUInt32: (val) ->
|
||||
@writeByte (val >>> 24) & 0xff
|
||||
@ -137,4 +137,4 @@ class Data
|
||||
for byte in bytes
|
||||
@writeByte byte
|
||||
|
||||
module.exports = Data
|
||||
module.exports = Data
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user