Skip to content

Commit 234b0ac

Browse files
committed
Fix index out of bounds
There is an index out of bounds when calling an iterator and it tried to construct a string of length 0. It calls copyMem on it but it fails because it has length 0. Exception is: index out of bounds, the container is empty src/easy_sqlite3/bindings.nim(532) getColumn
1 parent 83454e7 commit 234b0ac

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/easy_sqlite3/bindings.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ proc getColumn*(st: ref Statement, idx: int, T: typedesc[string]): string =
528528
let p = sqlite3_column_text(st.raw, idx)
529529
let l = sqlite3_column_bytes(st.raw, idx)
530530
result = newString l
531-
copyMem(addr result[0], p, l)
531+
if l > 0: copyMem(addr result[0], p, l)
532532

533533
proc getColumn*[T](st: ref Statement, idx: int, _: typedesc[Option[T]]): Option[T] =
534534
if st.getColumnType(idx) == dt_null:

0 commit comments

Comments
 (0)