diff --git a/src/funcs.c b/src/funcs.c
index 7fc0e5c..4641c8b 100644
--- a/src/funcs.c
+++ b/src/funcs.c
@@ -301,7 +301,7 @@ file_buffer(struct magic_set *ms, int fd, const char *inname __attribute__ ((unu
protected int
file_reset(struct magic_set *ms)
{
- if (ms->mlist[0] == NULL) {
+ if (ms->mlist == NULL) {
file_error(ms, 0, "no magic files loaded");
return -1;
}
diff --git a/src/softmagic.c b/src/softmagic.c
index def1e63..108d419 100644
--- a/src/softmagic.c
+++ b/src/softmagic.c
@@ -73,6 +73,10 @@ file_softmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes,
{
struct mlist *ml;
int rv, printed_something = 0, need_separator = 0;
+
+ if (!ms->mlist[0])
+ return 0;
+
for (ml = ms->mlist[0]->next; ml != ms->mlist[0]; ml = ml->next)
if ((rv = match(ms, ml->magic, ml->nmagic, buf, nbytes, 0, mode,
text, 0, 0, &printed_something, &need_separator,