Fix invalid memory access in debug code

This commit is contained in:
Přemysl Eric Janouch 2017-05-21 00:24:47 +02:00
parent cbce0d6498
commit 4d15d9cc6b
Signed by: p
GPG Key ID: B715679E3A361BE6
1 changed files with 5 additions and 6 deletions

11
ell.c
View File

@ -1116,17 +1116,16 @@ main (int argc, char *argv[]) {
parser_init (&parser, buf.s, buf.len - 1); parser_init (&parser, buf.s, buf.len - 1);
const char *e = NULL; const char *e = NULL;
struct item *program = parser_run (&parser, &e); struct item *program = parser_run (&parser, &e);
free (buf.s);
if (e) {
printf ("%s: %s\n", "parse error", e);
return 1;
}
#ifndef NDEBUG #ifndef NDEBUG
printf ("\x1b[1m%s\x1b[0m\n", buf.s); printf ("\x1b[1m%s\x1b[0m\n", buf.s);
print_tree (program, 0); print_tree (program, 0);
printf ("\n\n"); printf ("\n\n");
#endif #endif
free (buf.s);
if (e) {
printf ("%s: %s\n", "parse error", e);
return 1;
}
parser_free (&parser); parser_free (&parser);
struct context ctx; struct context ctx;