s3-vfs: Don't leak file descriptor on error.
authorAndreas Schneider <asn@samba.org>
Wed, 20 Feb 2013 09:45:06 +0000 (10:45 +0100)
committerAlexander Bokovoy <ab@samba.org>
Fri, 22 Feb 2013 15:36:14 +0000 (16:36 +0100)
Reviewed-by: Alexander Bokovoy <ab@samba.org>
source3/modules/vfs_crossrename.c

index 19a182c453cc0229f608374753c9354c12adf4f3..9bb42b9958ee9c793f342736dbbd97b378aa1a30 100644 (file)
@@ -73,8 +73,10 @@ static int copy_reg(const char *source, const char *dest)
        if((ifd = open (source, O_RDONLY, 0)) < 0)
                return -1;
 
-       if (unlink (dest) && errno != ENOENT)
+       if (unlink (dest) && errno != ENOENT) {
+               close(ifd);
                return -1;
+       }
 
 #ifdef O_NOFOLLOW
        if((ofd = open (dest, O_WRONLY | O_CREAT | O_TRUNC | O_NOFOLLOW, 0600)) < 0 )