From 6c9631d7eacd578772f45f4b72607975557f64bf Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Wed, 19 Jun 2019 17:15:47 +0200 Subject: [PATCH] Fix prefs_get_str related leaks in unit tests Related to https://github.com/profanity-im/profanity/issues/1019 --- tests/unittests/test_cmd_otr.c | 3 +++ tests/unittests/test_cmd_presence.c | 9 +++++++++ tests/unittests/test_preferences.c | 3 +++ 3 files changed, 15 insertions(+) diff --git a/tests/unittests/test_cmd_otr.c b/tests/unittests/test_cmd_otr.c index ffb6f785..ec879ab4 100644 --- a/tests/unittests/test_cmd_otr.c +++ b/tests/unittests/test_cmd_otr.c @@ -59,6 +59,7 @@ void cmd_otr_log_on_enables_logging(void **state) assert_true(result); assert_string_equal("on", pref_otr_log); + prefs_free_string(pref_otr_log); } void cmd_otr_log_on_shows_warning_when_chlog_disabled(void **state) @@ -87,6 +88,7 @@ void cmd_otr_log_off_disables_logging(void **state) assert_true(result); assert_string_equal("off", pref_otr_log); + prefs_free_string(pref_otr_log); } void cmd_otr_redact_redacts_logging(void **state) @@ -102,6 +104,7 @@ void cmd_otr_redact_redacts_logging(void **state) assert_true(result); assert_string_equal("redact", pref_otr_log); + prefs_free_string(pref_otr_log); } void cmd_otr_log_redact_shows_warning_when_chlog_disabled(void **state) diff --git a/tests/unittests/test_cmd_presence.c b/tests/unittests/test_cmd_presence.c index 74d4a132..54f69826 100644 --- a/tests/unittests/test_cmd_presence.c +++ b/tests/unittests/test_cmd_presence.c @@ -67,6 +67,7 @@ void cmd_presence_console_sets_all(void **state) assert_non_null(setting); assert_string_equal("all", setting); assert_true(result); + prefs_free_string(setting); } void cmd_presence_console_sets_online(void **state) @@ -81,6 +82,7 @@ void cmd_presence_console_sets_online(void **state) assert_non_null(setting); assert_string_equal("online", setting); assert_true(result); + prefs_free_string(setting); } void cmd_presence_console_sets_none(void **state) @@ -95,6 +97,7 @@ void cmd_presence_console_sets_none(void **state) assert_non_null(setting); assert_string_equal("none", setting); assert_true(result); + prefs_free_string(setting); } void cmd_presence_chat_sets_all(void **state) @@ -109,6 +112,7 @@ void cmd_presence_chat_sets_all(void **state) assert_non_null(setting); assert_string_equal("all", setting); assert_true(result); + prefs_free_string(setting); } void cmd_presence_chat_sets_online(void **state) @@ -123,6 +127,7 @@ void cmd_presence_chat_sets_online(void **state) assert_non_null(setting); assert_string_equal("online", setting); assert_true(result); + prefs_free_string(setting); } void cmd_presence_chat_sets_none(void **state) @@ -137,6 +142,7 @@ void cmd_presence_chat_sets_none(void **state) assert_non_null(setting); assert_string_equal("none", setting); assert_true(result); + prefs_free_string(setting); } void cmd_presence_room_sets_all(void **state) @@ -151,6 +157,7 @@ void cmd_presence_room_sets_all(void **state) assert_non_null(setting); assert_string_equal("all", setting); assert_true(result); + prefs_free_string(setting); } void cmd_presence_room_sets_online(void **state) @@ -165,6 +172,7 @@ void cmd_presence_room_sets_online(void **state) assert_non_null(setting); assert_string_equal("online", setting); assert_true(result); + prefs_free_string(setting); } void cmd_presence_room_sets_none(void **state) @@ -179,4 +187,5 @@ void cmd_presence_room_sets_none(void **state) assert_non_null(setting); assert_string_equal("none", setting); assert_true(result); + prefs_free_string(setting); } diff --git a/tests/unittests/test_preferences.c b/tests/unittests/test_preferences.c index c4bcbf77..05f34ca6 100644 --- a/tests/unittests/test_preferences.c +++ b/tests/unittests/test_preferences.c @@ -14,6 +14,7 @@ void statuses_console_defaults_to_all(void **state) assert_non_null(setting); assert_string_equal("all", setting); + prefs_free_string(setting); } void statuses_chat_defaults_to_all(void **state) @@ -22,6 +23,7 @@ void statuses_chat_defaults_to_all(void **state) assert_non_null(setting); assert_string_equal("all", setting); + prefs_free_string(setting); } void statuses_muc_defaults_to_all(void **state) @@ -30,4 +32,5 @@ void statuses_muc_defaults_to_all(void **state) assert_non_null(setting); assert_string_equal("all", setting); + prefs_free_string(setting); }