From e120b9156e758e881db5c13055c17999c62cfbd3 Mon Sep 17 00:00:00 2001
From: Piotr StefaƄski <stefanskipiotr15@gmail.com>
Date: Thu, 26 Oct 2023 20:34:17 +0200
Subject: Fix build failure when compiling in release

Compiling with --buildtype=release fails with message:

../main.c:935:17: error: argument 2 null where non-null expected [-Werror=nonnull]
  935 |                 memcpy(state->text + state->cursor, s, n);

GCC only produces this error with optimizations enabled. Looking at
the build output I assume this happens because it tries to inline the
function.
---
 main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/main.c b/main.c
index 9291119..056e0a3 100644
--- a/main.c
+++ b/main.c
@@ -931,7 +931,7 @@ void insert(struct menu_state *state, const char *s, ssize_t n) {
 	}
 	memmove(state->text + state->cursor + n, state->text + state->cursor,
 			sizeof state->text - state->cursor - MAX(n, 0));
-	if (n > 0) {
+	if (n > 0 && s != NULL) {
 		memcpy(state->text + state->cursor, s, n);
 	}
 	state->cursor += n;
-- 
cgit v1.2.3