aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nimpb/nimpb.nim2
1 files changed, 1 insertions, 1 deletions
diff --git a/nimpb/nimpb.nim b/nimpb/nimpb.nim
index 9933b18..260b379 100644
--- a/nimpb/nimpb.nim
+++ b/nimpb/nimpb.nim
@@ -399,7 +399,7 @@ proc protoWriteBytes*(stream: Stream, bytes: seq[byte], fieldNumber: int) =
proc safeReadStr*(stream: Stream, size: int): string =
result = newString(size)
- if readData(stream, addr(result[0]), size) != size:
+ if 0 < size and readData(stream, addr(result[0]), size) != size:
raise newException(IOError, "cannot read from stream")
proc protoReadString*(stream: Stream): string =