diff options
| author | Martin Trojer <martin.trojer@gmail.com> | 2026-10-29 08:35:02 +0000 |
|---|---|---|
| committer | Simon Ser <contact@emersion.fr> | 2026-10-29 09:38:09 +0100 |
| commit | 701a352e7eb03f5daf4252ea0a0f7aa437819b71 (patch) | |
| tree | 185c5fd20cbe7f608d2cb2af1887bdf19cfe5108 | |
| parent | 6ad9ebf3e14deac54a298c10df3e8701061fe495 (diff) | |
An expansion can yield no words (e.g. -i '' or an unset variable),
which made join_args() assert and swaylock abort before locking.
Use an empty path in that case, so loading it fails normally and
swaylock carries on and locks, instead of falling back to the
unexpanded string. Also free path and output_name on the
failed-load return.
| -rw-r--r-- | main.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -383,14 +383,20 @@ static void load_image(char *arg, struct swaylock_state *state) { *ptr = '\\'; } if (wordexp(image->path, &p, 0) == 0) { + // An expansion can yield no words (e.g. an empty or unset variable). + // Use an empty path then: loading it fails below, without falling + // back to the unexpanded string. free(image->path); - image->path = join_args(p.we_wordv, p.we_wordc); + image->path = p.we_wordc > 0 ? + join_args(p.we_wordv, p.we_wordc) : strdup(""); wordfree(&p); } // Load the actual image image->cairo_surface = load_background_image(image->path); if (!image->cairo_surface) { + free(image->output_name); + free(image->path); free(image); return; } |
