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.
Calling strncpy where the size of the string to copy is equal to the
size of the destination can potentially lead to a buffer overflow. To
fix this, copy only what is needed with memcpy, and explicitly terminate
the string with a null character.