m-settings: Fix the crash with empty settings

Add a null check when iterator gets the value to detect the end of the
JSON object, this will ensure the rest of the code that operates on the
value is bypassed.

Still it must be noted that an empty setting screws up the following
settings and behavior is undefined, this is the limiation in the
spa-json parsing.
This commit is contained in:
Ashok Sidipotu 2022-05-20 10:18:41 +05:30 committed by Julian Bouzas
parent 8a0c4fde4c
commit 3011a1c07e
2 changed files with 3 additions and 3 deletions

View file

@ -160,7 +160,8 @@ do_parse_settings (void *data, const char *location,
int len = 0;
g_value_unset (&item);
wp_iterator_next (iter, &item);
if (!wp_iterator_next (iter, &item))
break;
j = g_value_get_boxed (&item);
value = wp_spa_json_parse_string (j);
@ -190,7 +191,7 @@ static int
do_parse_endpoints (void *data, const char *location,
const char *section, const char *str, size_t len)
{
do_parse_settings (data, location, section, str, len);
return do_parse_settings (data, location, section, str, len);
}
static void

View file

@ -33,7 +33,6 @@ wireplumber.components = [
# Switch bluetooth profile based on media.role
{ name = policy-bluetooth.lua , type = script/lua }
]
wireplumber.settings = {