From: Sebastian Harl Date: Sat, 4 Jun 2016 16:25:06 +0000 (+0200) Subject: utils_mount_test: Free dynamically allocated strings. X-Git-Tag: collectd-5.6.0~243^2~4 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=fd4843d02bd03ddf170e92d22e36e5b522e19168;p=collectd.git utils_mount_test: Free dynamically allocated strings. --- diff --git a/src/utils_mount_test.c b/src/utils_mount_test.c index d9d685ae..dc6f79f9 100644 --- a/src/utils_mount_test.c +++ b/src/utils_mount_test.c @@ -25,6 +25,7 @@ */ #include "collectd.h" +#include "common.h" #include "testing.h" #include "utils_mount.h" @@ -80,16 +81,25 @@ DEF_TEST(cu_mount_getoptionvalue) { char line_opts[] = "foo=one,bar=two,qux=three"; char line_bool[] = "one,two,three"; - - EXPECT_EQ_STR ("one", cu_mount_getoptionvalue (line_opts, "foo=")); - EXPECT_EQ_STR ("two", cu_mount_getoptionvalue (line_opts, "bar=")); - EXPECT_EQ_STR ("three", cu_mount_getoptionvalue (line_opts, "qux=")); - OK (NULL == cu_mount_getoptionvalue (line_opts, "unknown=")); - - EXPECT_EQ_STR ("", cu_mount_getoptionvalue (line_bool, "one")); - EXPECT_EQ_STR ("", cu_mount_getoptionvalue (line_bool, "two")); - EXPECT_EQ_STR ("", cu_mount_getoptionvalue (line_bool, "three")); - OK (NULL == cu_mount_getoptionvalue (line_bool, "four")); + char *v; + + EXPECT_EQ_STR ("one", v = cu_mount_getoptionvalue (line_opts, "foo=")); + sfree (v); + EXPECT_EQ_STR ("two", v = cu_mount_getoptionvalue (line_opts, "bar=")); + sfree (v); + EXPECT_EQ_STR ("three", v = cu_mount_getoptionvalue (line_opts, "qux=")); + sfree (v); + OK (NULL == (v = cu_mount_getoptionvalue (line_opts, "unknown="))); + sfree (v); + + EXPECT_EQ_STR ("", v = cu_mount_getoptionvalue (line_bool, "one")); + sfree (v); + EXPECT_EQ_STR ("", v = cu_mount_getoptionvalue (line_bool, "two")); + sfree (v); + EXPECT_EQ_STR ("", v = cu_mount_getoptionvalue (line_bool, "three")); + sfree (v); + OK (NULL == (v = cu_mount_getoptionvalue (line_bool, "four"))); + sfree (v); return (0); }