From 1795014dae4320fd95846cc2dd1786d672e389e5 Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Wed, 25 Mar 2020 17:15:06 +0900 Subject: [PATCH] throw an error on get-output-string on non-string-ports (issue #621) --- sexp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sexp.c b/sexp.c index 647865ac..ec7ede7d 100644 --- a/sexp.c +++ b/sexp.c @@ -1708,6 +1708,8 @@ sexp sexp_get_output_string_op (sexp ctx, sexp self, sexp_sint_t n, sexp out) { sexp_assert_type(ctx, sexp_oportp, SEXP_OPORT, out); if (!sexp_port_openp(out)) return sexp_xtype_exception(ctx, self, "output port is closed", out); + if (!sexp_pairp(sexp_port_cookie(out))) + return sexp_xtype_exception(ctx, self, "not a string output port", out); sexp_gc_preserve3(ctx, ls, rev, tmp); if (sexp_port_offset(out) > 0) { tmp = sexp_c_string(ctx, sexp_port_buf(out), sexp_port_offset(out));