Fix buffer overflow and remove use of Z_Malloc()

Z_Malloc is not needed here because any paths bigger than MAX_QPATH will fail / get truncated elsewhere