From 4c77afc17eb5447a1ae06241478afe11f7db607d Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Mon, 16 Sep 2024 19:41:27 -0500 Subject: [PATCH] Fix #198 - Check for unintialized raw stream. --- src/rawterm.c | 1 + test/suite-rawterm.janet | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/rawterm.c b/src/rawterm.c index 6a35b0c..632be66 100644 --- a/src/rawterm.c +++ b/src/rawterm.c @@ -222,6 +222,7 @@ static void rawterm_begin(void) { } static void rawterm_getch(JanetBuffer *buf) { + if (rawterm_stream == NULL) janet_panic("call rawterm/begin to initialize"); janet_ev_read(rawterm_stream, buf, 1); janet_await(); } diff --git a/test/suite-rawterm.janet b/test/suite-rawterm.janet index befa1be..fcfb9f0 100644 --- a/test/suite-rawterm.janet +++ b/test/suite-rawterm.janet @@ -3,6 +3,8 @@ (start-suite) +(assert-error "issue #198" (rawterm/getch)) + # TODO: This tests the reduced set of codepoints based on the original set in # Bestline: # https://github.com/jart/bestline/blob/4a09bf4355c15c96526/bestline.c#L274-L287