[glib] GVariant parser: turn two asserts into soft errors
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] GVariant parser: turn two asserts into soft errors
- Date: Fri, 19 Apr 2013 15:40:22 +0000 (UTC)
commit 1d87c6c7f818eef758a2bd6afd07f6feabc5f45d
Author: Ryan Lortie <desrt desrt ca>
Date: Wed Apr 17 12:08:00 2013 -0400
GVariant parser: turn two asserts into soft errors
Parsing wrongly-typed GVariant text format data is a well-defined
operation and it ought to result in a GError. We do that for most
cases, but 'v' and 'ay' were being treated differently. Fix those as
well.
glib/gvariant-parser.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/glib/gvariant-parser.c b/glib/gvariant-parser.c
index d5c036a..1421a34 100644
--- a/glib/gvariant-parser.c
+++ b/glib/gvariant-parser.c
@@ -1142,7 +1142,9 @@ variant_get_value (AST *ast,
Variant *variant = (Variant *) ast;
GVariant *child;
- g_assert (g_variant_type_equal (type, G_VARIANT_TYPE_VARIANT));
+ if (!g_variant_type_equal (type, G_VARIANT_TYPE_VARIANT))
+ return ast_type_error (ast, type, error);
+
child = ast_resolve (variant->value, error);
if (child == NULL)
@@ -1656,7 +1658,8 @@ bytestring_get_value (AST *ast,
{
ByteString *string = (ByteString *) ast;
- g_assert (g_variant_type_equal (type, G_VARIANT_TYPE_BYTESTRING));
+ if (!g_variant_type_equal (type, G_VARIANT_TYPE_BYTESTRING))
+ return ast_type_error (ast, type, error);
return g_variant_new_bytestring (string->string);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]