diff --git a/CHANGES.txt b/CHANGES.txt
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,5 +1,7 @@
 Changelog for Hexml
 
+0.3.1
+    #9, don't walk off the end of the character table
 0.3
     #8, Mac compatibility
     Fix a bug when parsing closing comments
diff --git a/cbits/fuzz.c b/cbits/fuzz.c
new file mode 100644
--- /dev/null
+++ b/cbits/fuzz.c
@@ -0,0 +1,26 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "hexml.c"
+
+int main(int ac, char** av)
+{
+#ifdef __AFL_HAVE_MANUAL_CONTROL
+    __AFL_INIT();
+#endif
+
+    FILE *f = fopen(av[1], "rb");
+    fseek(f, 0, SEEK_END);
+    size_t fsize = ftell(f);
+    rewind(f);
+
+    char* string = malloc(fsize+1);
+    memset(string, 0, fsize+1);
+    (void) fread(string, fsize, 1, f);
+    fclose(f);
+
+    document *doc = hexml_document_parse(string, fsize);
+    hexml_document_free(doc);
+    free(string);
+    return 0;
+}
diff --git a/cbits/hexml.c b/cbits/hexml.c
--- a/cbits/hexml.c
+++ b/cbits/hexml.c
@@ -240,7 +240,7 @@
     done = 1;
 }
 
-static inline bool is(char c, char tag) { return parse_table[c] & tag; }
+static inline bool is(char c, char tag) { return parse_table[(unsigned char) c] & tag; }
 static inline bool is_name1(char c) { return is(c, tag_name1); }
 static inline bool is_name(char c) { return is(c, tag_name); }
 static inline bool is_space(char c) { return is(c, tag_space); }
diff --git a/cbits/main.c b/cbits/main.c
new file mode 100644
--- /dev/null
+++ b/cbits/main.c
@@ -0,0 +1,46 @@
+#include "hexml.h"
+#include <stdio.h>
+#include <malloc.h>
+#include <time.h>
+#include <string.h>
+#include <assert.h>
+
+char* readFile(char* file)
+{
+    FILE* f = fopen(file, "rb");
+    fseek(f, 0, SEEK_END);
+    int len = ftell(f);
+    fseek(f, 0, SEEK_SET);
+    char* res = malloc(len + 1);
+    assert(res);
+    res[len] = 0;
+    size_t n = fread(res, 1, len, f);
+    assert(n == len);
+    fclose(f);
+    return res;
+}
+
+char* example = "<?xml version=\"1.0\" lang=\"ja\"?><foo><bar baz=\"qux\">quux</bar><bar baz=\"bar\">hoge</bar><piyo>&gt;piyopiyo&lt;</piyo></foo><foo2 />";
+
+int main(int argc, char **argv)
+{
+    setbuf(stdout, NULL);
+    char* body = argv[1] == NULL ? example : readFile(argv[1]);
+    document* doc = hexml_document_parse(body, -1);
+    char* err = hexml_document_error(doc);
+    if (err == NULL)
+    {
+        int len = hexml_node_render(doc, hexml_document_node(doc), NULL, 0);
+        char* s = malloc(len + 1);
+        assert(s);
+        hexml_node_render(doc, hexml_document_node(doc), s, len);
+        s[len] = 0;
+        printf("Parse successful\n"); // , %s\n", s);
+        return 0;
+    }
+    else
+    {
+        printf("Parse failed, %s\n", err);
+        return 1;
+    }
+}
diff --git a/hexml.cabal b/hexml.cabal
--- a/hexml.cabal
+++ b/hexml.cabal
@@ -1,7 +1,7 @@
 cabal-version:      >= 1.18
 build-type:         Simple
 name:               hexml
-version:            0.3
+version:            0.3.1
 license:            BSD3
 license-file:       LICENSE
 category:           XML
