From: Christos Zoulas Date: Tue, 3 May 2016 16:09:38 +0000 (+0000) Subject: pointless to try to deal with -1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3804ab0b142469926fdddc11687446c78dc68b1f;p=file pointless to try to deal with -1 --- diff --git a/src/magic.c b/src/magic.c index 8b7960b9..a256c42f 100644 --- a/src/magic.c +++ b/src/magic.c @@ -33,7 +33,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: magic.c,v 1.98 2016/04/19 20:51:54 christos Exp $") +FILE_RCSID("@(#)$File: magic.c,v 1.99 2016/05/03 16:09:38 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; }