protected wrong buffer-length write by initializing to 0, but there is more debugging...