Skip to content

Commit

Permalink
Merge pull request #60 from christopher-dG/cdg/overflow
Browse files Browse the repository at this point in the history
Fix uint8 overflow
  • Loading branch information
quinnj authored Jun 1, 2020
2 parents 304ae9f + f31a800 commit f5f396a
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\""

2 comments on commit f5f396a

@quinnj
Copy link
Owner Author

@quinnj quinnj commented on f5f396a Jun 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/15696

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.3 -m "<description of version>" f5f396ad8e60899c60e87c7337989ac9a4ef1a35
git push origin v1.0.3

Please sign in to comment.