Hi Marcel,
On Tue, Jan 4, 2011 at 3:31 PM, Marcel Holtmann <marcel(a)holtmann.org> wrote:
> diff --git a/src/dbus.c b/src/dbus.c
> index c24615f..292f11a 100644
> --- a/src/dbus.c
> +++ b/src/dbus.c
> @@ -139,8 +139,13 @@ static void append_dict_variant(DBusMessageIter *iter, int type,
void *val)
>
> dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING,
> &(val_array[i + 0]));
> - dbus_message_iter_append_basic(&entry, type,
> - &(val_array[i + 1]));
> + if (type == DBUS_TYPE_STRING) {
> + dbus_message_iter_append_basic(&entry, type,
> + &(val_array[i + 1]));
> + } else {
> + dbus_message_iter_append_basic(&entry, type,
> + val_array[i + 1]);
> + }
this does looks a bit hackish. Can you put it into context please. It
might be that our call chain is wrong.
As of now there are no calls to ofono_dbus_dict_append_dict() with
type != string. So, there's no problem in current code base. The
problem arrives when I call, for example:
void **array;
array = g_new0(void *, 4);
array[0] = a_string;
array[1] = &a_byte_var;
array[2] = b_string;
array[3] = &b_byte_var;
then if i call:
ofono_dbus_dict_append_dict(&dict, "MyPropName", DBUS_TYPE_BYTE,
&array);
It will not work, because of the following call chain:
ofono_dbus_dict_append_dict()
append_dict_variant(... , void *val)
const void **val_array = *(const void ***) val;
(...)
dbus_message_iter_append_basic(&entry, DBUS_TYPE_BYTE,
&(val_array[i + 1]);
So, you are passing a const void** to dbus_message_iter_append_basic
that will be dereferenced accordingly inside dbus to get the type you
told it. Then, bad things will happen. I've just tested here with my
patches for the retry counter, where this call is needed.
regards,
Lucas De Marchi