[Spice-devel] [PATCH spice v3 3/3] Do not crash on NULL codecs
Pavel Grunt
pgrunt at redhat.com
Wed Nov 16 15:20:44 UTC 2016
---
server/reds.c | 2 ++
server/tests/spice-codecs-parsing-test.c | 15 ++++++++++++++-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/server/reds.c b/server/reds.c
index 12a274c..8344177 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3639,6 +3639,8 @@ static void reds_set_video_codecs(RedsState *reds, const char *codecs)
{
char *encoder_name, *codec_name;
+ g_return_if_fail(codecs != NULL);
+
if (strcmp(codecs, "auto") == 0) {
codecs = default_video_codecs;
}
diff --git a/server/tests/spice-codecs-parsing-test.c b/server/tests/spice-codecs-parsing-test.c
index 9db321d..0e23553 100644
--- a/server/tests/spice-codecs-parsing-test.c
+++ b/server/tests/spice-codecs-parsing-test.c
@@ -59,33 +59,46 @@ static void codecs_bad(void)
guint i;
const struct {
const gchar *codecs;
+ const GLogLevelFlags log_level;
const gchar *error_message;
} test_cases[] = {
{
+ NULL,
+ G_LOG_LEVEL_CRITICAL,
+ "*assertion 'codecs != NULL' failed"
+ },{
";:;",
+ G_LOG_LEVEL_WARNING,
"*spice: invalid encoder:codec value*",
},{
"::::",
+ G_LOG_LEVEL_WARNING,
"*spice: invalid encoder:codec value*",
},{
"missingcolon",
+ G_LOG_LEVEL_WARNING,
"*spice: invalid encoder:codec value*",
},{
":missing_encoder",
+ G_LOG_LEVEL_WARNING,
"*spice: invalid encoder:codec value*",
},{
"missing_value:;",
+ G_LOG_LEVEL_WARNING,
"*spice: invalid encoder:codec value*",
},{
"unknown_encoder:mjpeg",
+ G_LOG_LEVEL_WARNING,
"*spice: unknown video encoder unknown_encoder",
},{
"spice:unknown_codec",
+ G_LOG_LEVEL_WARNING,
"*spice: unknown video codec unknown_codec",
},
#if !defined(HAVE_GSTREAMER_1_0) && !defined(HAVE_GSTREAMER_0_10)
{
"gstreamer:mjpeg",
+ G_LOG_LEVEL_WARNING,
"*spice: unsupported video encoder gstreamer",
}
#endif
@@ -96,7 +109,7 @@ static void codecs_bad(void)
g_assert_nonnull(server);
for (i = 0; i < G_N_ELEMENTS(test_cases); ++i) {
- g_test_expect_message(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, test_cases[i].error_message);
+ g_test_expect_message(G_LOG_DOMAIN, test_cases[i].log_level, test_cases[i].error_message);
g_assert_cmpint(spice_server_set_video_codecs(server, test_cases[i].codecs), ==, 0);
g_test_assert_expected_messages();
}
--
2.10.2
More information about the Spice-devel
mailing list