#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"
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;
}