diff --git a/libp2p/stream/lpstream.nim b/libp2p/stream/lpstream.nim index 1a56c84..8357333 100644 --- a/libp2p/stream/lpstream.nim +++ b/libp2p/stream/lpstream.nim @@ -276,7 +276,7 @@ proc readLp*(s: LPStream, maxSize: int): Future[seq[byte]] {.async, gcsafe, publ if length == 0: return - var res = newSeq[byte](length) + var res = newSeqUninitialized[byte](length) await s.readExactly(addr res[0], res.len) return res diff --git a/libp2p/vbuffer.nim b/libp2p/vbuffer.nim index 4992f6a..5becf45 100644 --- a/libp2p/vbuffer.nim +++ b/libp2p/vbuffer.nim @@ -43,7 +43,7 @@ proc initVBuffer*(data: seq[byte], offset = 0): VBuffer = proc initVBuffer*(data: openArray[byte], offset = 0): VBuffer = ## Initialize VBuffer with copy of ``data``. - result.buffer = newSeq[byte](len(data)) + result.buffer = newSeqUninitialized[byte](len(data)) if len(data) > 0: copyMem(addr result.buffer[0], unsafeAddr data[0], len(data)) result.offset = offset