It doesn't copy the null terminator because it's using memcpy. It's only copying the string without the null byte.
For real programs you basically have to put it in the initial computation, or it will be forgotten somewhere later (maybe in a later commit).
Mayhaps "len" should be renamed to something clearer?