From cb8ed6722a3c52692e708d3b9bde5ccf99e5d4ac Mon Sep 17 00:00:00 2001 From: fox0430 Date: Mon, 13 Apr 2026 16:32:18 +0900 Subject: [PATCH] Add bounds check to isNull --- async_postgres/pg_types.nim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/async_postgres/pg_types.nim b/async_postgres/pg_types.nim index 72dbd78..08635da 100644 --- a/async_postgres/pg_types.nim +++ b/async_postgres/pg_types.nim @@ -1620,6 +1620,10 @@ proc contains*(cr: CommandResult, s: string): bool {.inline.} = proc isNull*(row: Row, col: int): bool = ## Check if the column value is NULL. + if col < 0 or col >= int(row.data.numCols): + raise newException( + IndexDefect, "column index " & $col & " out of range 0..<" & $row.data.numCols + ) let idx = (int(row.rowIdx) * int(row.data.numCols) + col) * 2 row.data.cellIndex[idx + 1] == -1'i32