]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[Unit-tests] Fix leaks in mod_test and in switch_core_codec, switch_vpx, switch_xml...
authorAndrey Volk <andywolk@gmail.com>
Wed, 27 Nov 2019 17:36:53 +0000 (21:36 +0400)
committerAndrey Volk <andywolk@gmail.com>
Wed, 27 Nov 2019 17:38:19 +0000 (21:38 +0400)
src/mod/applications/mod_test/mod_test.c
tests/unit/switch_core_codec.c
tests/unit/switch_ivr_play_say.c
tests/unit/switch_vpx.c

index d5460ac364856652010eb61110cb33d447af51cf..c8ce62c39f77cfa5464fd39578ce376b5355dbc7 100644 (file)
@@ -257,8 +257,6 @@ static switch_status_t test_asr_get_results(switch_asr_handle_t *ah, char **resu
 {
        test_asr_t *context = (test_asr_t *) ah->private_info;
        switch_status_t status = SWITCH_STATUS_SUCCESS;
-       switch_stream_handle_t result = { 0 };
-       SWITCH_STANDARD_STREAM(result);
 
        if (switch_test_flag(context, ASRFLAG_RETURNED_RESULT) || switch_test_flag(ah, SWITCH_ASR_FLAG_CLOSED)) {
                return SWITCH_STATUS_FALSE;
index b01d5220c5a91aa9fbbb0d05ebf8b9f95485eeae..61a70314a4d9ec3a56cf7c6fda5b0923475b2c89 100644 (file)
@@ -74,6 +74,8 @@ FST_CORE_BEGIN("./conf")
                        switch_core_codec_copy(&orig_codec, &new_codec, NULL, NULL);
                        fst_check(orig_codec.implementation->samples_per_second == new_codec.implementation->samples_per_second);
                        fst_check(orig_codec.implementation->actual_samples_per_second == new_codec.implementation->actual_samples_per_second);
+                       switch_core_codec_destroy(&orig_codec);
+                       switch_core_codec_destroy(&new_codec);
 
                        status = switch_core_codec_init(&orig_codec,
                        "OPUS",
@@ -88,6 +90,8 @@ FST_CORE_BEGIN("./conf")
                        switch_core_codec_copy(&orig_codec, &new_codec, NULL, NULL);
                        fst_check(orig_codec.implementation->samples_per_second == new_codec.implementation->samples_per_second);
                        fst_check(orig_codec.implementation->actual_samples_per_second == new_codec.implementation->actual_samples_per_second);
+                       switch_core_codec_destroy(&orig_codec);
+                       switch_core_codec_destroy(&new_codec);
 
                        status = switch_core_codec_init(&orig_codec,
                        "OPUS",
@@ -102,6 +106,8 @@ FST_CORE_BEGIN("./conf")
                        switch_core_codec_copy(&orig_codec, &new_codec, NULL, NULL);
                        fst_check(orig_codec.implementation->samples_per_second == new_codec.implementation->samples_per_second);
                        fst_check(orig_codec.implementation->actual_samples_per_second == new_codec.implementation->actual_samples_per_second);
+                       switch_core_codec_destroy(&orig_codec);
+                       switch_core_codec_destroy(&new_codec);
  
                        status = switch_core_codec_init(&orig_codec,
                        "G722",
@@ -116,6 +122,8 @@ FST_CORE_BEGIN("./conf")
                        switch_core_codec_copy(&orig_codec, &new_codec, NULL, NULL);
                        fst_check(orig_codec.implementation->samples_per_second == new_codec.implementation->samples_per_second);
                        fst_check(orig_codec.implementation->actual_samples_per_second == new_codec.implementation->actual_samples_per_second);
+                       switch_core_codec_destroy(&orig_codec);
+                       switch_core_codec_destroy(&new_codec);
 
                }
                FST_TEST_END()
index c08cdd5752d09f44a16a90c3e24e5bc9f2f6acec..6dd1c524f50b963acd57c2372626a57abbca1553 100644 (file)
@@ -261,6 +261,8 @@ FST_CORE_BEGIN("./conf_playsay")
                        fst_check_string_equals(cJSON_GetObjectCstr(recognition_result, "text"), "");
                        fst_check_string_equals(digits_collected, NULL);
                        fst_check(terminator_collected == 0);
+                       if (recognition_result) cJSON_Delete(recognition_result);
+                       recognition_result = NULL;
                }
                FST_SESSION_END()
        }
index 505b27f09a52964613dbb741fbe9f8c70cd2d01a..d97d09f186f52d8cf5a3c178443a96f7163d3060 100644 (file)
@@ -82,6 +82,7 @@ FST_CORE_BEGIN("./conf")
                        fst_check(frame.m == 1);
                        fst_check(packets > 0);
 
+                       switch_img_free(&img);
                        switch_core_codec_destroy(&codec);
                }
                FST_TEST_END()