diff --git a/src/test/test-xdg-autostart.c b/src/test/test-xdg-autostart.c index cc75bc6024..70287b3c55 100644 --- a/src/test/test-xdg-autostart.c +++ b/src/test/test-xdg-autostart.c @@ -67,7 +67,7 @@ static void test_xdg_desktop_parse(unsigned i, const char *s) { case 0: assert_se(streq(service->exec_string, "/bin/sleep 100")); assert_se(strv_equal(service->only_show_in, STRV_MAKE("A", "B"))); - assert_se(strv_equal(service->not_show_in, STRV_MAKE("C", "", "D\\;", "E"))); + assert_se(strv_equal(service->not_show_in, STRV_MAKE("C", "D\\;", "E"))); assert_se(!service->hidden); break; case 1: @@ -81,14 +81,12 @@ static void test_xdg_desktop_parse(unsigned i, const char *s) { } int main(int argc, char *argv[]) { - size_t i; - test_setup_logging(LOG_DEBUG); test_translate_name(); test_xdg_format_exec_start(); - for (i = 0; i < ELEMENTSOF(xdg_desktop_file); i++) + for (size_t i = 0; i < ELEMENTSOF(xdg_desktop_file); i++) test_xdg_desktop_parse(i, xdg_desktop_file[i]); return 0; diff --git a/src/xdg-autostart-generator/xdg-autostart-service.c b/src/xdg-autostart-generator/xdg-autostart-service.c index a19d2d7e24..4a30f9e433 100644 --- a/src/xdg-autostart-generator/xdg-autostart-service.c +++ b/src/xdg-autostart-generator/xdg-autostart-service.c @@ -192,6 +192,9 @@ static int strv_strndup_unescape_and_push( const char *start, const char *end) { + if (end == start) + return 0; + _cleanup_free_ char *copy = NULL; int r; @@ -270,14 +273,12 @@ static int xdg_config_parse_strv( } } - /* Any trailing entry should be ignored if it is empty. */ - if (end > start) { - r = strv_strndup_unescape_and_push(unit, filename, line, - &sv, &n_allocated, &n, - start, end); - if (r < 0) - return r; - } + /* Handle the trailing entry after the last separator */ + r = strv_strndup_unescape_and_push(unit, filename, line, + &sv, &n_allocated, &n, + start, end); + if (r < 0) + return r; *ret_sv = TAKE_PTR(sv); return 0;