I think you still want to check the error return value here and only set `tdir` to `template_buf.ptr` if this succeeds.