Skip to content

Commit

Permalink
Fix uint8 overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
christopher-dG committed Jun 1, 2020
1 parent 304ae9f commit f31a800
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name = "JSON3"
uuid = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
authors = ["Jacob Quinn <[email protected]>"]
version = "1.0.2"
version = "1.0.3"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Mmap = "a63ad114-7e13-5084-954f-fe012c677804"
Parsers = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
StructTypes = "856f2bd8-1eba-4b0a-8007-ebc267875bd4"
Mmap = "a63ad114-7e13-5084-954f-fe012c677804"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"

[compat]
Parsers = "0.3, 1"
Expand Down
4 changes: 2 additions & 2 deletions src/write.jl
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ const ESCAPELENS = [length(x) for x in ESCAPECHARS]
function escapelength(str)
x = 0
@simd for i = 1:ncodeunits(str)
@inbounds len = ESCAPELENS[codeunit(str, i) + 0x01]
@inbounds len = ESCAPELENS[codeunit(str, i) + 1]
x += len
end
return x
Expand All @@ -239,7 +239,7 @@ function write(::StringType, buf, pos, len, x::AbstractString; kw...)
@inbounds @writechar '"'
if el > sz
for i = 1:sz
@inbounds escbytes = ESCAPECHARS[codeunit(x, i) + 0x01]
@inbounds escbytes = ESCAPECHARS[codeunit(x, i) + 1]
for j = 1:length(escbytes)
@inbounds buf[pos] = escbytes[j]
pos += 1
Expand Down
3 changes: 3 additions & 0 deletions test/json.jl
Original file line number Diff line number Diff line change
Expand Up @@ -723,3 +723,6 @@ end
@test JSON3.write([Int64[] Int64[]]') == "[]"

@test Float32(JSON3.read(JSON3.write(2.1f-8))) == 2.1f-8

# PR 60
@test JSON3.write(String([0xff])) == "\"\xff\""

0 comments on commit f31a800

Please sign in to comment.