diff options
author | Stef Walter <stefw@gnome.org> | 2013-03-20 20:59:26 +0100 |
---|---|---|
committer | Stef Walter <stefw@gnome.org> | 2013-03-20 22:22:22 +0100 |
commit | 57d8f36a6cfbde5a9a783f11f2b75f19005c23e1 (patch) | |
tree | d21f862a9698ef6066ce2b14ef82fbd8c370f9ac /common/tests/test-compat.c | |
parent | 9cf89e4b43e5e018bb3103be1873a3993769ce4a (diff) |
Fix invalid memory accesses reported by 'make memcheck'
These are things that showed up in valgrind while running the tests.
Diffstat (limited to 'common/tests/test-compat.c')
-rw-r--r-- | common/tests/test-compat.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/common/tests/test-compat.c b/common/tests/test-compat.c index 13a7a33..a94aaeb 100644 --- a/common/tests/test-compat.c +++ b/common/tests/test-compat.c @@ -72,6 +72,21 @@ test_basename (CuTest *tc) } } +static void +test_strndup (CuTest *tc) +{ + char unterminated[] = { 't', 'e', 's', 't', 'e', 'r', 'o', 'n', 'i', 'o' }; + char *res; + + res = strndup (unterminated, 6); + CuAssertStrEquals (tc, res, "tester"); + free (res); + + res = strndup ("test", 6); + CuAssertStrEquals (tc, res, "test"); + free (res); +} + int main (void) { @@ -80,6 +95,7 @@ main (void) int ret; SUITE_ADD_TEST (suite, test_basename); + SUITE_ADD_TEST (suite, test_strndup); CuSuiteRun (suite); CuSuiteSummary (suite, output); |