diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2024-07-31 16:31:18 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2024-07-31 16:33:24 +0000 |
| commit | 18b87b2e206536d2fdda36e8c42cce270c77a54b (patch) | |
| tree | cf699e378f410bec9095f61b3f756b33de7d6b69 | |
| parent | osc: kitty notifications: buttons, icons, app-name, categories etc (diff) | |
notify: don't forget terminating NULL when patching notify helper's argv
| -rw-r--r-- | notify.c | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -476,18 +476,21 @@ notify_notify(struct terminal *term, struct notification *notif) if (action_argc == 0) { free(argv[i]); - memmove(&argv[i], &argv[i + 1], (argc - i - 1) * sizeof(argv[0])); - argv[argc--] = NULL; + + /* Remove ${command-arg}, but include terminating NULL */ + memmove(&argv[i], &argv[i + 1], (argc - i) * sizeof(argv[0])); + argc--; break; } - /* Remove the "${action-arg}" entry, add all actions argument from earlier */ - argv = xrealloc(argv, (argc + action_argc - 1) * sizeof(argv[0])); + /* Remove the "${action-arg}" entry, add all actions argument + from earlier, but include terminating NULL */ + argv = xrealloc(argv, (argc + action_argc) * sizeof(argv[0])); /* Move remaining arguments to after the action arguments */ memmove(&argv[i + action_argc], &argv[i + 1], - (argc - (i + 1)) * sizeof(argv[0])); + (argc - i) * sizeof(argv[0])); /* Include terminating NULL */ free(argv[i]); /* Free xstrdup("${action-arg}"); */ @@ -501,10 +504,11 @@ notify_notify(struct terminal *term, struct notification *notif) argc--; /* The ${action-arg} option has been removed */ break; } - + LOG_DBG("notify command:"); for (size_t i = 0; i < argc; i++) LOG_DBG(" argv[%zu] = \"%s\"", i, argv[i]); + xassert(argv[argc] == NULL); int stdout_fds[2] = {-1, -1}; if (track_notification) { |
