Merge pull request #241 from signalwire/mod_rayo_leak

[mod_rayo] Fix leak in the mod and in tests.
This commit is contained in:
Andrey Volk 2020-01-20 13:44:50 +04:00 committed by GitHub
commit f1c1f9085c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 10 deletions

View File

@ -356,6 +356,12 @@ enum nlsml_match_type nlsml_parse(const char *nlsml_result, const char *uuid)
}
end:
while (parser.cur) {
struct nlsml_node *node = parser.cur;
parser.cur = node->parent;
free(node);
}
if ( p ) {
iks_parser_delete(p);
}

View File

@ -164,15 +164,27 @@ FST_TEST_END()
FST_TEST_BEGIN(dialback_key)
{
fst_check_string_equals("37c69b1cf07a3f67c04a5ef5902fa5114f2c76fe4a2686482ba5b89323075643", iks_server_dialback_key("s3cr3tf0rd14lb4ck", "xmpp.example.com", "example.org", "D60000229F"));
fst_check(NULL == iks_server_dialback_key("", "xmpp.example.com", "example.org", "D60000229F"));
fst_check(NULL == iks_server_dialback_key("s3cr3tf0rd14lb4ck", "", "example.org", "D60000229F"));
fst_check(NULL == iks_server_dialback_key("s3cr3tf0rd14lb4ck", "xmpp.example.com", "", "D60000229F"));
fst_check(NULL == iks_server_dialback_key("s3cr3tf0rd14lb4ck", "xmpp.example.com", "example.org", ""));
fst_check(NULL == iks_server_dialback_key(NULL, "xmpp.example.com", "example.org", "D60000229F"));
fst_check(NULL == iks_server_dialback_key("s3cr3tf0rd14lb4ck", NULL, "example.org", "D60000229F"));
fst_check(NULL == iks_server_dialback_key("s3cr3tf0rd14lb4ck", "xmpp.example.com", NULL, "D60000229F"));
fst_check(NULL == iks_server_dialback_key("s3cr3tf0rd14lb4ck", "xmpp.example.com", "example.org", NULL));
char *dialback_key;
dialback_key = iks_server_dialback_key("s3cr3tf0rd14lb4ck", "xmpp.example.com", "example.org", "D60000229F");
fst_check_string_equals("37c69b1cf07a3f67c04a5ef5902fa5114f2c76fe4a2686482ba5b89323075643", dialback_key);
switch_safe_free(dialback_key);
fst_check(NULL == (dialback_key = iks_server_dialback_key("", "xmpp.example.com", "example.org", "D60000229F")));
switch_safe_free(dialback_key);
fst_check(NULL == (dialback_key = iks_server_dialback_key("s3cr3tf0rd14lb4ck", "", "example.org", "D60000229F")));
switch_safe_free(dialback_key);
fst_check(NULL == (dialback_key = iks_server_dialback_key("s3cr3tf0rd14lb4ck", "xmpp.example.com", "", "D60000229F")));
switch_safe_free(dialback_key);
fst_check(NULL == (dialback_key = iks_server_dialback_key("s3cr3tf0rd14lb4ck", "xmpp.example.com", "example.org", "")));
switch_safe_free(dialback_key);
fst_check(NULL == (dialback_key = iks_server_dialback_key(NULL, "xmpp.example.com", "example.org", "D60000229F")));
switch_safe_free(dialback_key);
fst_check(NULL == (dialback_key = iks_server_dialback_key("s3cr3tf0rd14lb4ck", NULL, "example.org", "D60000229F")));
switch_safe_free(dialback_key);
fst_check(NULL == (dialback_key = iks_server_dialback_key("s3cr3tf0rd14lb4ck", "xmpp.example.com", NULL, "D60000229F")));
switch_safe_free(dialback_key);
fst_check(NULL == (dialback_key = iks_server_dialback_key("s3cr3tf0rd14lb4ck", "xmpp.example.com", "example.org", NULL)));
switch_safe_free(dialback_key);
}
FST_TEST_END()

View File

@ -301,6 +301,7 @@ FST_TEST_BEGIN(create_dtmf_match)
result_str = iks_string(NULL, result);
fst_check_string_equals(nlsml_dtmf_result, result_str);
iks_free(result_str);
iks_delete(result);
}
FST_TEST_END()
@ -316,6 +317,7 @@ FST_TEST_BEGIN(create_dtmf_instance)
result_str = iks_string(NULL, result);
fst_check_string_equals(nlsml_dtmf_instance_result, result_str);
iks_free(result_str);
iks_delete(result);
}
FST_TEST_END()
@ -325,8 +327,13 @@ FST_TEST_END()
FST_TEST_BEGIN(normalize)
{
iks *result = nlsml_normalize(nlsml_good);
char *result_str;
fst_requires(result);
fst_check_string_equals(nlsml_good_normalized, iks_string(NULL, result));
result_str = iks_string(NULL, result);
fst_check_string_equals(nlsml_good_normalized, result_str);
iks_free(result_str);
iks_delete(result);
}
FST_TEST_END()

View File

@ -1200,6 +1200,7 @@ FST_TEST_BEGIN(repeat_item_range_ambiguous_grammar)
fst_check(SMT_MATCH == srgs_grammar_match(grammar, "1", &interpretation));
fst_check(SMT_MATCH == srgs_grammar_match(grammar, "12", &interpretation));
fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "123", &interpretation));
srgs_parser_destroy(parser);
}
FST_TEST_END()
@ -1217,6 +1218,7 @@ FST_TEST_BEGIN(repeat_item_range_optional_pound_grammar)
fst_check(SMT_MATCH == srgs_grammar_match(grammar, "12", &interpretation));
fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "12#", &interpretation));
fst_check(SMT_MATCH_END == srgs_grammar_match(grammar, "123", &interpretation));
srgs_parser_destroy(parser);
}
FST_TEST_END()
@ -1253,6 +1255,7 @@ FST_TEST_BEGIN(w3c_example_grammar)
fst_requires((grammar = srgs_parse(parser, w3c_example_grammar)));
fst_check(srgs_grammar_to_jsgf(grammar));
srgs_parser_destroy(parser);
}
FST_TEST_END()
@ -1266,6 +1269,7 @@ FST_TEST_BEGIN(metadata_grammar)
fst_requires((grammar = srgs_parse(parser, metadata_grammar)));
fst_check(srgs_grammar_to_jsgf(grammar));
srgs_parser_destroy(parser);
}
FST_TEST_END()