aboutsummaryrefslogtreecommitdiff
path: root/encoding.c
diff options
context:
space:
mode:
Diffstat (limited to 'encoding.c')
-rw-r--r--encoding.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/encoding.c b/encoding.c
index 097673adacd1..dee57a6e8f58 100644
--- a/encoding.c
+++ b/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.7 2012/01/24 19:02:02 christos 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";
@@ -133,8 +133,7 @@ file_encoding(struct magic_set *ms, const unsigned char *buf, size_t nbytes, uni
}
done:
- if (nbuf)
- free(nbuf);
+ free(nbuf);
return rv;
}