Make sure we free up the buffer on a failure