core/load-fragment: avoid allocating 0 bytes when given an invalid command

With a command line like "@/something" we would allocate an array with
0 elements. Avoid that, and add a test too.

(cherry picked from commit e01ff42899)

Conflicts:
	src/core/load-fragment.c
	src/test/test-unit-file.c
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2015-01-16 00:05:51 -05:00
parent f948c51a7a
commit 4c35b425f8
+2 -1
View File
@@ -581,7 +581,8 @@ int config_parse_exec(const char *unit,
}
found:
n = new(char*, k + !honour_argv0);
/* If seperate_argv0, we'll move first element to path variable */
n = new(char*, MAX(k + !honour_argv0, 1u));
if (!n)
return log_oom();