Fix build failure when compiling in release - wmenu - 🔧 fork of wmenu
 (HTM) git clone git@git.drkhsh.at/wmenu.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit e120b9156e758e881db5c13055c17999c62cfbd3
 (DIR) parent adf5cda6e18dd1b0ce9fbde71200f79a816ecb91
 (HTM) Author: Piotr Stefański <stefanskipiotr15@gmail.com>
       Date:   Thu, 26 Oct 2023 20:34:17 +0200
       
       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.
       
       Diffstat:
         M main.c                              |       2 +-
       
       1 file changed, 1 insertion(+), 1 deletion(-)
       ---
 (DIR) diff --git 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;