From 1a2b71688d5c71a10c2c1d8acb0098d2e4584a38 Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Sun, 5 Jul 2015 23:15:45 +0900 Subject: [PATCH] error instead of segfault for invalid/forged brace literals --- sexp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sexp.c b/sexp.c index 5863683a..967409b5 100644 --- a/sexp.c +++ b/sexp.c @@ -2717,7 +2717,8 @@ sexp sexp_read_raw (sexp ctx, sexp in) { tmp = sexp_read_error(ctx, "brace literal missing type identifier", sexp_make_character(c1), in); } if (!sexp_exceptionp(tmp)) tmp = sexp_lookup_type(ctx, res, tmp); - if (tmp && sexp_typep(tmp) && sexp_opcodep(sexp_type_print(tmp)) + if (tmp && sexp_typep(tmp) && sexp_type_print(tmp) + && sexp_opcodep(sexp_type_print(tmp)) && sexp_opcode_func(sexp_type_print(tmp)) == (sexp_proc1)sexp_write_simple_object) { res = sexp_alloc_tagged(ctx, sexp_type_size_base(tmp), sexp_type_tag(tmp)); for (c1=0; ; c1++) {