From 00cf293cf0f1d6a3a69a3fe497860203b2bdae06 Mon Sep 17 00:00:00 2001 From: fox0430 Date: Mon, 13 Apr 2026 16:45:24 +0900 Subject: [PATCH] Clarify body slice calculation in parseBackendMessage --- async_postgres/pg_protocol.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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