Merge pull request #26 from status-im/unsafememoryinput-empty-array-access
don't even notionally access element 0 of 0-length openArray
This commit is contained in:
commit
c80701f7d2
4 changed files with 4 additions and 4 deletions
|
|
@ -11,7 +11,7 @@ type
|
|||
startAddr*, endAddr*: ptr byte
|
||||
|
||||
Page* = object
|
||||
consumedTo*: Natural
|
||||
consumedTo*: int
|
||||
writtenTo*: Natural
|
||||
data*: ref string
|
||||
|
||||
|
|
|
|||
|
|
@ -442,7 +442,7 @@ proc fileInput*(filename: string,
|
|||
return fileInput(file, offset, pageSize)
|
||||
|
||||
proc unsafeMemoryInput*(mem: openArray[byte]): InputStreamHandle =
|
||||
let head = unsafeAddr mem[0]
|
||||
let head = cast[ptr byte](mem)
|
||||
|
||||
makeHandle InputStream(
|
||||
span: PageSpan(
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ proc base64decode*(i: InputStream, o: OutputStream) {.fsMultiSync.} =
|
|||
inputChar(d)
|
||||
outputChar(c shl 6 or d shr 0)
|
||||
elif i.readable:
|
||||
raise newException(ValueError, "The input stream has insufficient nymber of bytes for base64 decoding")
|
||||
raise newException(ValueError, "The input stream has insufficient number of bytes for base64 decoding")
|
||||
|
||||
close o
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ when fsAsyncSupport:
|
|||
template timeit(timerVar: var Nanos, code: untyped) =
|
||||
let t0 = getTicks()
|
||||
code
|
||||
timerVar = int(getTicks() - t0) div 1000000
|
||||
timerVar = int64(getTicks() - t0) div 1000000
|
||||
|
||||
proc getOutput(sp: AsyncInputStream, T: type string): Future[string] {.async.} =
|
||||
# this proc is a quick hack to let the test pass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue