fixes #22153; UB calling allocCStringArray([""]) with --mm:refc (#24529)

fixes #22153

It's a problem for refc because you cannot index a nil string: i.e.
`[""]` is `{((NimStringDesc*) NIM_NIL)}` which cannot be indexed

(cherry picked from commit 9bb7e53e7f)
This commit is contained in:
ringabout
2024-12-12 04:02:24 +08:00
committed by narimiran
parent 2f5481ce88
commit 5b0b90fb49
2 changed files with 9 additions and 1 deletions

View File

@@ -13,3 +13,11 @@ var info = ForkedEpochInfo(kind: true)
doAssert info.kind
info.kind = false
doAssert not info.kind
block: # bug #22153
discard allocCStringArray([""])
discard allocCStringArray(["1234"])
var s = "1245"
s.add "1"
discard allocCStringArray([s])