Fix possible fd leak if fd==0

Reported by:	Coverity Scan