gvariant: Ensure GVS.depth is initialised

When byteswapping the depth was accidentally left uninitialised.

Coverity CID: #1430636
Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
Philip Withnall 2020-08-18 09:46:12 +01:00
parent fb6da5677b
commit a5d34a7c78
3 changed files with 18 additions and 0 deletions

View File

@ -666,6 +666,21 @@ g_variant_is_trusted (GVariant *value)
return (value->state & STATE_TRUSTED) != 0;
}
/* < internal >
* g_variant_get_depth:
* @value: a #GVariant
*
* Gets the nesting depth of a #GVariant. This is 0 for a #GVariant with no
* children.
*
* Returns: nesting depth of @value
*/
gsize
g_variant_get_depth (GVariant *value)
{
return value->depth;
}
/* -- public -- */
/**

View File

@ -34,4 +34,6 @@ gboolean g_variant_is_trusted (GVarian
GVariantTypeInfo * g_variant_get_type_info (GVariant *value);
gsize g_variant_get_depth (GVariant *value);
#endif /* __G_VARIANT_CORE_H__ */

View File

@ -5952,6 +5952,7 @@ g_variant_byteswap (GVariant *value)
serialised.type_info = g_variant_get_type_info (trusted);
serialised.size = g_variant_get_size (trusted);
serialised.data = g_malloc (serialised.size);
serialised.depth = g_variant_get_depth (trusted);
g_variant_store (trusted, serialised.data);
g_variant_unref (trusted);