Fix file descriptor leak

(Thanks to Brent Cook)

OK from jsing@
Free "data" when it's no longer in use.

(Thanks to Brent Cook)

OK from jsing@