Skip to content

Commit

Permalink
Check for nil in cstringArrayToSeq
Browse files Browse the repository at this point in the history
  • Loading branch information
yglukhov committed Jun 21, 2024
1 parent 646bd99 commit d72b064
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/system.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2102,12 +2102,14 @@ when not defined(js):
proc cstringArrayToSeq*(a: cstringArray, len: Natural): seq[string] =
## Converts a `cstringArray` to a `seq[string]`. `a` is supposed to be
## of length `len`.
if a == nil: return
newSeq(result, len)
for i in 0..len-1: result[i] = $a[i]

proc cstringArrayToSeq*(a: cstringArray): seq[string] =
## Converts a `cstringArray` to a `seq[string]`. `a` is supposed to be
## terminated by `nil`.
if a == nil: return
var L = 0
while a[L] != nil: inc(L)
result = cstringArrayToSeq(a, L)
Expand Down

0 comments on commit d72b064

Please sign in to comment.