summaryrefslogtreecommitdiff
path: root/src/encoding.c
diff options
context:
space:
mode:
authorChristos Zoulas <christos@zoulas.com>2012-01-24 19:02:02 +0000
committerChristos Zoulas <christos@zoulas.com>2012-01-24 19:02:02 +0000
commit7414932da237e210a41366d6dbdc4f7cbbc68521 (patch)
treed34ae21cb78422285a639793a6f531b18c4b2410 /src/encoding.c
parentecf2a9db3dd81c1749dd53917247854c3a3f16f7 (diff)
downloadfile-git-7414932da237e210a41366d6dbdc4f7cbbc68521.tar.gz
make sure that type is initialized even in the out of memory case.
Diffstat (limited to 'src/encoding.c')
-rw-r--r--src/encoding.c4
1 files changed, 2 insertions, 2 deletions
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";