mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
notify: don't forget terminating NULL when patching notify helper's argv
This commit is contained in:
parent
76ac910b11
commit
18b87b2e20
1 changed files with 10 additions and 6 deletions
16
notify.c
16
notify.c
|
|
@ -476,18 +476,21 @@ notify_notify(struct terminal *term, struct notification *notif)
|
||||||
|
|
||||||
if (action_argc == 0) {
|
if (action_argc == 0) {
|
||||||
free(argv[i]);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove the "${action-arg}" entry, add all actions argument from earlier */
|
/* Remove the "${action-arg}" entry, add all actions argument
|
||||||
argv = xrealloc(argv, (argc + action_argc - 1) * sizeof(argv[0]));
|
from earlier, but include terminating NULL */
|
||||||
|
argv = xrealloc(argv, (argc + action_argc) * sizeof(argv[0]));
|
||||||
|
|
||||||
/* Move remaining arguments to after the action arguments */
|
/* Move remaining arguments to after the action arguments */
|
||||||
memmove(&argv[i + action_argc],
|
memmove(&argv[i + action_argc],
|
||||||
&argv[i + 1],
|
&argv[i + 1],
|
||||||
(argc - (i + 1)) * sizeof(argv[0]));
|
(argc - i) * sizeof(argv[0])); /* Include terminating NULL */
|
||||||
|
|
||||||
free(argv[i]); /* Free xstrdup("${action-arg}"); */
|
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 */
|
argc--; /* The ${action-arg} option has been removed */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_DBG("notify command:");
|
LOG_DBG("notify command:");
|
||||||
for (size_t i = 0; i < argc; i++)
|
for (size_t i = 0; i < argc; i++)
|
||||||
LOG_DBG(" argv[%zu] = \"%s\"", i, argv[i]);
|
LOG_DBG(" argv[%zu] = \"%s\"", i, argv[i]);
|
||||||
|
xassert(argv[argc] == NULL);
|
||||||
|
|
||||||
int stdout_fds[2] = {-1, -1};
|
int stdout_fds[2] = {-1, -1};
|
||||||
if (track_notification) {
|
if (track_notification) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue