]> arthur.barton.de Git - netatalk.git/commitdiff
Fix fd leakage
authorFrank Lahm <franklahm@googlemail.com>
Fri, 2 Mar 2012 14:27:12 +0000 (15:27 +0100)
committerFrank Lahm <franklahm@googlemail.com>
Fri, 2 Mar 2012 14:27:12 +0000 (15:27 +0100)
libatalk/adouble/ad_open.c

index 8c0c21d099bcf77150919189b808b7d16e3ca7bf..b0ffba071b9dc569f4d8bffd95c2db129a1706af 100644 (file)
@@ -514,11 +514,13 @@ static int ad_header_read(const char *path _U_, struct adouble *ad, const struct
 int ad_valid_header_osx(const char *path)
 {
     EC_INIT;
-    int fd;
+    int fd = -1;
     struct adouble      adosx;
     char                *buf = &adosx.ad_data[0];
     ssize_t             header_len;
 
+    LOG(log_debug, logtype_afpd, "ad_valid_header_osx(\"%s\"): BEGIN", fullpathname(path));
+
     EC_NEG1( fd = open(path, O_RDONLY) );
 
     /* read the header */
@@ -538,6 +540,9 @@ int ad_valid_header_osx(const char *path)
     }
 
 EC_CLEANUP:
+    LOG(log_debug, logtype_afpd, "ad_valid_header_osx(\"%s\"): END: %d", fullpathname(path), ret);
+    if (fd != -1)
+        close(fd);
     if (ret != 0)
         return 1;
     return 0;