#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: apprentice.c,v 1.170 2011/06/10 09:23:28 christos Exp $")
+FILE_RCSID("@(#)$File: apprentice.c,v 1.171 2011/09/16 21:04:59 christos Exp $")
#endif /* lint */
#include "magic.h"
file_oomem(ms,
strlen(fn) + strlen(d->d_name) + 2);
errs++;
+ closedir(dir);
goto out;
}
if (stat(mfn, &st) == -1 || !S_ISREG(st.st_mode)) {
realloc(filearr, mlen))) == NULL) {
file_oomem(ms, mlen);
free(mfn);
+ closedir(dir);
errs++;
goto out;
}
apprentice_compile(struct magic_set *ms, struct magic **magicp,
uint32_t *nmagicp, const char *fn)
{
- int fd;
+ int fd = -1;
char *dbname;
int rv = -1;
goto out;
}
- (void)close(fd);
+ if (fd != -1)
+ (void)close(fd);
rv = 0;
out:
free(dbname);