summaryrefslogtreecommitdiff
path: root/test/test-misc.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2018-06-11 10:45:58 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2018-06-11 13:43:15 +1000
commit6ad928a1b6de8e8102086f8d36623540d248b41e (patch)
tree1c4bb2a9d8712c95b54e4ae1831f220ff3c0b726 /test/test-misc.c
parent46b64c73633cb73bfa23b7f141f9e9ed88c66992 (diff)
downloadlibinput-6ad928a1b6de8e8102086f8d36623540d248b41e.tar.gz
util: add null string test handling to strv_join
Make it return NULL for a string array in the form of [ NULL ], like the docs say. This also adds an extra safety check for the joiner to be of a reasonable length to avoid overflows. Found in https://gitlab.freedesktop.org/libinput/libinput/issues/26#note_6320 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'test/test-misc.c')
-rw-r--r--test/test-misc.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/test/test-misc.c b/test/test-misc.c
index ea262f65..50fe018f 100644
--- a/test/test-misc.c
+++ b/test/test-misc.c
@@ -1366,6 +1366,7 @@ START_TEST(strjoin_test)
{ { NULL }, NULL, NULL }
};
struct strjoin_test *t = tests;
+ struct strjoin_test nulltest = { {NULL}, "x", NULL };
while (t->strv[0]) {
char *str;
@@ -1377,6 +1378,8 @@ START_TEST(strjoin_test)
free(str);
t++;
}
+
+ ck_assert(strv_join(nulltest.strv, "x") == NULL);
}
END_TEST