From df69adb4702a9abc59f9e98ebeea1e13c73b66a3 Mon Sep 17 00:00:00 2001 From: Christos Zoulas Date: Thu, 10 Jul 2003 21:07:14 +0000 Subject: [PATCH] We need ms struct initialized. --- src/magic.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/magic.c b/src/magic.c index 61f1a335..e3a454c6 100644 --- a/src/magic.c +++ b/src/magic.c @@ -65,7 +65,7 @@ #include "patchlevel.h" #ifndef lint -FILE_RCSID("@(#)$Id: magic.c,v 1.9 2003/07/10 17:41:24 christos Exp $") +FILE_RCSID("@(#)$Id: magic.c,v 1.10 2003/07/10 21:07:14 christos Exp $") #endif /* lint */ #ifdef __EMX__ @@ -87,13 +87,15 @@ magic_open(int flags) { struct magic_set *ms; + if ((ms = malloc(sizeof(struct magic_set))) == NULL) + return NULL; + if (magic_setflags(ms, flags) == -1) { + free(ms); errno = EINVAL; return NULL; } - if ((ms = malloc(sizeof(struct magic_set))) == NULL) - return NULL; ms->o.ptr = ms->o.buf = malloc(ms->o.size = 1024); ms->o.len = 0; if (ms->o.buf == NULL) { -- 2.40.0