I think you can't simply cast the slice.data to a cstring. It has to be delimited by a "0" which may "happen" for accident in your code. But it would be really to have behind slice.size bytes in memory.
Looking into the memfiles module you can see how it is done to return lines as strings [here](https://github.com/nim-lang/Nim/blob/master/lib/pure/memfiles.nim#L319-L334) I guess that should help to work out on how to create a string from the slice.
