From: Christos Zoulas Date: Tue, 24 Jan 2012 19:02:02 +0000 (+0000) Subject: make sure that type is initialized even in the out of memory case. X-Git-Tag: FILE5_11~13 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7414932da237e210a41366d6dbdc4f7cbbc68521;p=file make sure that type is initialized even in the out of memory case. --- diff --git a/src/encoding.c b/src/encoding.c index ee5b5716..ca55720b 100644 --- a/src/encoding.c +++ b/src/encoding.c @@ -35,7 +35,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: encoding.c,v 1.5 2010/07/21 16:47:17 christos Exp $") +FILE_RCSID("@(#)$File: encoding.c,v 1.6 2011/12/08 12:38:24 rrt Exp $") #endif /* lint */ #include "magic.h" @@ -71,6 +71,7 @@ file_encoding(struct magic_set *ms, const unsigned char *buf, size_t nbytes, uni int rv = 1, ucs_type; unsigned char *nbuf = NULL; + *type = "text"; mlen = (nbytes + 1) * sizeof(nbuf[0]); if ((nbuf = CAST(unsigned char *, calloc((size_t)1, mlen))) == NULL) { file_oomem(ms, mlen); @@ -82,7 +83,6 @@ file_encoding(struct magic_set *ms, const unsigned char *buf, size_t nbytes, uni goto done; } - *type = "text"; if (looks_ascii(buf, nbytes, *ubuf, ulen)) { DPRINTF(("ascii %" SIZE_T_FORMAT "u\n", *ulen)); *code = "ASCII";