summaryrefslogtreecommitdiff
path: root/ext/fileinfo/libmagic/encoding.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fileinfo/libmagic/encoding.c')
-rw-r--r--ext/fileinfo/libmagic/encoding.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/ext/fileinfo/libmagic/encoding.c b/ext/fileinfo/libmagic/encoding.c
index dee57a6e8f..b75e0ccb7f 100644
--- a/ext/fileinfo/libmagic/encoding.c
+++ b/ext/fileinfo/libmagic/encoding.c
@@ -35,7 +35,7 @@
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: encoding.c,v 1.7 2012/01/24 19:02:02 christos Exp $")
+FILE_RCSID("@(#)$File: encoding.c,v 1.9 2013/11/19 20:45:50 christos Exp $")
#endif /* lint */
#include "magic.h"
@@ -72,13 +72,17 @@ file_encoding(struct magic_set *ms, const unsigned char *buf, size_t nbytes, uni
unsigned char *nbuf = NULL;
*type = "text";
- mlen = (nbytes + 1) * sizeof(nbuf[0]);
- if ((nbuf = CAST(unsigned char *, calloc((size_t)1, mlen))) == NULL) {
+ *ulen = 0;
+ *code = "unknown";
+ *code_mime = "binary";
+
+ mlen = (nbytes + 1) * sizeof((*ubuf)[0]);
+ if ((*ubuf = CAST(unichar *, calloc((size_t)1, mlen))) == NULL) {
file_oomem(ms, mlen);
goto done;
}
- mlen = (nbytes + 1) * sizeof((*ubuf)[0]);
- if ((*ubuf = CAST(unichar *, calloc((size_t)1, mlen))) == NULL) {
+ mlen = (nbytes + 1) * sizeof(nbuf[0]);
+ if ((nbuf = CAST(unsigned char *, calloc((size_t)1, mlen))) == NULL) {
file_oomem(ms, mlen);
goto done;
}