File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed
Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change 11## Unreleased
22 - Support for directly reading from and writing to Vector{UInt8}
33 - Fix for working with opened IOStream objects
4+ - Proper boundscheck for internal ` read_bytestring `
45
56## 0.6.3
67 - Fix edge case in datatype loading (#692 )
Original file line number Diff line number Diff line change @@ -201,14 +201,13 @@ end
201201
202202# Read a null-terminated string
203203function read_bytestring(io:: MmapIO )
204- # Find the null terminator position without allocating
205204 ptr = pconvert(Ptr{UInt8}, io. curptr)
206- len = 0
207- while unsafe_load (ptr, len + 1 ) != 0x00
208- len += 1
209- end
210- str = len == 0 ? " " : unsafe_string(ptr, len )
211- io. curptr += len + 1
205+ maxbytes = io . endptr - io . curptr + 1
206+ q = @ccall memchr (ptr:: Ptr{UInt8} , 0 :: Int32 , maxbytes :: Csize_t ) :: Ptr{UInt8}
207+ q == C_NULL && throw(EOFError())
208+
209+ str = unsafe_string(ptr, (q - ptr) % Int )
210+ io. curptr += (q - ptr) % Int + 1
212211 str
213212end
214213
@@ -239,4 +238,4 @@ function end_checksum(io::MmapIO)
239238 @inbounds v = io. checksum_pos[io. nchecksum]
240239 io. nchecksum -= 1
241240 Lookup3. hash(Ptr{UInt8}(io. startptr + v), position(io) - v)
242- end
241+ end
You can’t perform that action at this time.
0 commit comments