fix CID#11102 : close a dup fd before every return statement