diff --git a/async_postgres/pg_protocol.nim b/async_postgres/pg_protocol.nim index ec7497a..8a449a7 100644 --- a/async_postgres/pg_protocol.nim +++ b/async_postgres/pg_protocol.nim @@ -953,9 +953,9 @@ proc parseBackendMessage*( # Body is the region after type byte and 4-byte length let bodyStart = 5 - let bodyEnd = bodyStart + int(msgLen) - 4 - 1 + let bodyLen = int(msgLen) - 4 # msgLen includes the 4-byte length field itself template body(): untyped = - buf.toOpenArray(bodyStart, bodyEnd) + buf.toOpenArray(bodyStart, bodyStart + bodyLen - 1) var msg: BackendMessage