summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2015-01-11 16:52:50 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2015-01-11 23:41:42 -0500
commit4d8629de8bd0f837f99981267d10e71d1f72e47d (patch)
tree4531239689e15a5950e1af515c24a947b22a6532 /src
parent17a1c597c5f9be1c25431a764155cd50c0d074b7 (diff)
test-unit-file: don't access out-of-bounds memory
Fixes an error introduced by me when the test was added.
Diffstat (limited to 'src')
-rw-r--r--src/test/test-unit-file.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/test/test-unit-file.c b/src/test/test-unit-file.c
index 6a146a702f..d6a7d43915 100644
--- a/src/test/test-unit-file.c
+++ b/src/test/test-unit-file.c
@@ -73,15 +73,20 @@ static void check_execcommand(ExecCommand *c,
const char* argv1,
const char* argv2,
bool ignore) {
+ size_t n;
+
assert_se(c);
log_info("expect: \"%s\" [\"%s\" \"%s\" \"%s\"]",
path, argv0 ?: path, argv1, argv2);
+ n = strv_length(c->argv);
log_info("actual: \"%s\" [\"%s\" \"%s\" \"%s\"]",
- c->path, c->argv[0], c->argv[1], c->argv[2]);
+ c->path, c->argv[0], n > 0 ? c->argv[1] : NULL, n > 1 ? c->argv[2] : NULL);
assert_se(streq(c->path, path));
assert_se(streq(c->argv[0], argv0 ?: path));
- assert_se(streq_ptr(c->argv[1], argv1));
- assert_se(streq_ptr(c->argv[2], argv2));
+ if (n > 0)
+ assert_se(streq_ptr(c->argv[1], argv1));
+ if (n > 1)
+ assert_se(streq_ptr(c->argv[2], argv2));
assert_se(c->ignore == ignore);
}