Skip to content

Commit

Permalink
Fix crash when an invalid field name is sent via D-Bus. Closes: #817.
Browse files Browse the repository at this point in the history
Regression introduced by commit 203b41f.
  • Loading branch information
jlindgren90 committed Aug 19, 2018
1 parent 8f9745a commit 1528e78
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions src/audacious/dbus-server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -635,27 +635,30 @@ static gboolean do_song_title (Obj * obj, Invoc * invoc, unsigned pos)
static gboolean do_song_tuple (Obj * obj, Invoc * invoc, unsigned pos, const char * key)
{
Tuple::Field field = Tuple::field_by_name (key);
Tuple tuple;
GVariant * var;
GVariant * var = nullptr;

if (field >= 0)
tuple = CURRENT.entry_tuple (pos);

switch (tuple.get_value_type (field))
{
case Tuple::String:
var = g_variant_new_string (tuple.get_str (field));
break;
Tuple tuple = CURRENT.entry_tuple (pos);

case Tuple::Int:
var = g_variant_new_int32 (tuple.get_int (field));
break;
switch (tuple.get_value_type (field))
{
case Tuple::String:
var = g_variant_new_string (tuple.get_str (field));
break;

default:
var = g_variant_new_string ("");
break;
case Tuple::Int:
var = g_variant_new_int32 (tuple.get_int (field));
break;

default:
break;
}
}

if (! var)
var = g_variant_new_string ("");

FINISH2 (song_tuple, g_variant_new_variant (var));
return true;
}
Expand Down

0 comments on commit 1528e78

Please sign in to comment.