Be sure to free the buffer in case of any exception.
Not that there's much chance of an exception from the problem areas of this code.