summaryrefslogtreecommitdiffstats
path: root/encoding.c
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>2012-04-13 23:30:38 +0000
committerobrien <obrien@FreeBSD.org>2012-04-13 23:30:38 +0000
commit15f98df7891f1853090ecb6c4a9cc734e671ef6b (patch)
tree76d27a13085cbcecae404c91dc1a6e03fc5c5d7b /encoding.c
parent75c49f9dd6a0ff710f7c791a485899c7a07af444 (diff)
downloadFreeBSD-src-15f98df7891f1853090ecb6c4a9cc734e671ef6b.zip
FreeBSD-src-15f98df7891f1853090ecb6c4a9cc734e671ef6b.tar.gz
Virgin import of Christos Zoulas's FILE 5.11.
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 097673a..dee57a6 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;
}
OpenPOWER on IntegriCloud