summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2024-08-23 22:27:03 +0200
committerLouis Burda <quent.burda@gmail.com>2024-08-23 22:27:03 +0200
commitd91d30cfaf5198d512ba3864f4c9cc17cc0504ef (patch)
treeff550c74d9edab82e86ddae91acbf2b0209d973d
parentd02ac078404fbe7b7138baee55d7a0332c544bfe (diff)
downloadxnote-d91d30cfaf5198d512ba3864f4c9cc17cc0504ef.tar.gz
xnote-d91d30cfaf5198d512ba3864f4c9cc17cc0504ef.zip
Check return value of glfwGetKeyName
-rw-r--r--xnote.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/xnote.c b/xnote.c
index c35193c..0541374 100644
--- a/xnote.c
+++ b/xnote.c
@@ -155,12 +155,12 @@ undo(void)
case EVENT_START_LINE:
case EVENT_START_NOTE:
case EVENT_START:
- goto exit;
+ break;
default:
continue;
}
+ break;
}
-exit:
shrink(&events, event_count, &event_cap, sizeof(enum event));
}
@@ -244,9 +244,10 @@ static void
key_press_cb(GLFWwindow *window, int key, int scancode, int action, int mods)
{
if (action == GLFW_PRESS || action == GLFW_REPEAT) {
- if ((mods & GLFW_MOD_CONTROL) && !strcmp(glfwGetKeyName(key, scancode), "z")) {
+ const char *keysym = glfwGetKeyName(key, scancode);
+ if ((mods & GLFW_MOD_CONTROL) && keysym && !strcmp(keysym, "z")) {
if (event_count) undo();
- } else if ((mods & GLFW_MOD_CONTROL) && !strcmp(glfwGetKeyName(key, scancode), "c")) {
+ } else if ((mods & GLFW_MOD_CONTROL) && keysym && !strcmp(keysym, "c")) {
for (size_t i = 0; i < line_count; i++)
free(lines[i].points);
line_count = 0;