From 802e95d876f0b2a44f6de192517dbcf6fe2a323b Mon Sep 17 00:00:00 2001 From: nick black Date: Sat, 5 Sep 2020 18:59:14 -0400 Subject: [PATCH] zoo: error check on notcurses_cursor_enable() #990 --- src/demo/zoo.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/demo/zoo.c b/src/demo/zoo.c index 24063c26b..445f629f6 100644 --- a/src/demo/zoo.c +++ b/src/demo/zoo.c @@ -158,12 +158,17 @@ layout_next_text(struct ncreader* reader, const char* text, size_t* textpos){ free(duped); return -1; } + free(duped); int y, x, posy, posx; struct ncplane* ncp = ncreader_plane(reader); ncplane_cursor_yx(ncp, &y, &x); ncplane_yx(ncp, &posy, &posx); - notcurses_cursor_enable(ncplane_notcurses(ncp), y + posy, x + posx); - free(duped); + int stdy = ncplane_dim_y(notcurses_stdplane(ncplane_notcurses(ncp))); + if(y + posy < stdy - 1){ + if(notcurses_cursor_enable(ncplane_notcurses(ncp), y + posy, x + posx)){ + return -1; + } + } *textpos += towrite; } return 0;