]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- fix condition on open() check
authorOndrej Kozina <okozina@redhat.com>
Wed, 30 Jan 2013 17:34:36 +0000 (18:34 +0100)
committerOndrej Kozina <okozina@redhat.com>
Wed, 27 Feb 2013 16:24:57 +0000 (17:24 +0100)
- close fd on error
- catch XAttributesException() during container construction

snapper/Compare.cc

index abf3fed2029f10d2b983780eb2d8d4563fd25633..c8cc5a03c7321cf3114f07772fa4f5345c486e47 100644 (file)
@@ -475,15 +475,27 @@ namespace snapper
         }
 
         int fd2 = file2.open(O_RDONLY | O_NOFOLLOW | O_NOATIME | O_CLOEXEC);
-        if (fd1 < 0)
+        if (fd2 < 0)
         {
             y2err("open failed path:" << file2.fullname() << " errno:" << errno);
+            close(fd1);
             throw IOErrorException();
         }
 
-        XAttributes xa(fd1), xb(fd2);
+        bool retval;
+
+        try
+        {
+            XAttributes xa(fd1), xb(fd2);
+            retval = (xa == xb);
+        }
+        catch (XAttributesException xae)
+        {
+            retval = false;
+        }
         close(fd1);
         close(fd2);
-        return (xa == xb);
+
+        return retval;
     }
 }