commit 2809473fd3803550b0870dd3ae606a9117c7876d
parent c8dfcd6bd48db415647598947b3276dda7a87c96
Author: Pavel Renev <an2qzavok@gmail.com>
Date: Sun, 15 Nov 2020 20:00:41 +0000
some nil pointer checks here and there
Diffstat:
1 file changed, 3 insertions(+), 0 deletions(-)
diff --git a/gophra.c b/gophra.c
@@ -302,6 +302,7 @@ drawmenu(void)
ulong n, line;
dp = rw.min;
draw(screen, rw, Iwbg, 0, ZP);
+ if (text.data == nil) return;
for(line = scroll;; line++){
/*
* n in stringn() counts characters, not bytes.
@@ -329,6 +330,8 @@ getlinep(Text *text, ulong ln)
{
ulong lcount;
char *lp;
+ assert(text != nil);
+ if (text->data == nil) return nil;
lp = text->data;
for (lcount = 0; lcount < ln; lp++){
if (*lp == '\n') lcount++;