diff options
| author | Louis Burda <quent.burda@gmail.com> | 2024-08-23 22:27:03 +0200 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2024-08-23 22:27:03 +0200 |
| commit | d91d30cfaf5198d512ba3864f4c9cc17cc0504ef (patch) | |
| tree | ff550c74d9edab82e86ddae91acbf2b0209d973d | |
| parent | d02ac078404fbe7b7138baee55d7a0332c544bfe (diff) | |
| download | xnote-d91d30cfaf5198d512ba3864f4c9cc17cc0504ef.tar.gz xnote-d91d30cfaf5198d512ba3864f4c9cc17cc0504ef.zip | |
Check return value of glfwGetKeyName
| -rw-r--r-- | xnote.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -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; |
