]> granicus.if.org Git - file/commitdiff
pointless to try to deal with -1
authorChristos Zoulas <christos@zoulas.com>
Tue, 3 May 2016 16:09:38 +0000 (16:09 +0000)
committerChristos Zoulas <christos@zoulas.com>
Tue, 3 May 2016 16:09:38 +0000 (16:09 +0000)
src/magic.c

index 8cf62694383d120600b55564bd376d5f65c4b366..4474793a1ecc3b440a2f24fb7bfb945d7d7230be 100644 (file)
@@ -33,7 +33,7 @@
 #include "file.h"
 
 #ifndef        lint
-FILE_RCSID("@(#)$File: magic.c,v 1.97 2016/03/31 17:51:12 christos Exp $")
+FILE_RCSID("@(#)$File: magic.c,v 1.98 2016/04/19 20:51:54 christos Exp $")
 #endif /* lint */
 
 #include "magic.h"
@@ -523,9 +523,11 @@ file_or_fd(struct magic_set *ms, const char *inname, int fd)
        rv = 0;
 done:
        free(buf);
-       if (pos != (off_t)-1)
-               (void)lseek(fd, pos, SEEK_SET);
-       close_and_restore(ms, inname, fd, &sb);
+       if (fd != -1) {
+               if (pos != (off_t)-1)
+                       (void)lseek(fd, pos, SEEK_SET);
+               close_and_restore(ms, inname, fd, &sb);
+       }
 out:
        return rv == 0 ? file_getbuffer(ms) : NULL;
 }