The code failed to allocate memory for the terminating 0-byte.
Reported by: @ronlieb
thanks for the quick response, lgtm.
LGTM, please commit