Permalink
Browse files

Fix crash when an invalid field name is sent via D-Bus. Closes: #817.

Regression introduced by commit 203b41f.
  • Loading branch information...
jlindgren90 committed Aug 19, 2018
1 parent 8f9745a commit 1528e780825b1fc49639ea16d332c5752051dab7
Showing with 17 additions and 14 deletions.
  1. +17 −14 src/audacious/dbus-server.cc
@@ -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;
}

0 comments on commit 1528e78

Please sign in to comment.