From 12e32e96a3b124791d09ca568e922307db83fe66 Mon Sep 17 00:00:00 2001 From: Maks Naumov Date: Thu, 15 Jan 2015 14:33:17 -0800 Subject: [PATCH] Don't skip invalid enum values in schemas Signed-off-by: Maks Naumov https://bugzilla.gnome.org/show_bug.cgi?id=742997 --- gio/glib-compile-schemas.c | 4 ++-- gio/tests/gschema-compile.c | 1 + .../schema-tests/enum-with-invalid-value.gschema.xml | 10 ++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 gio/tests/schema-tests/enum-with-invalid-value.gschema.xml diff --git a/gio/glib-compile-schemas.c b/gio/glib-compile-schemas.c index b8de09072..2dc8c7171 100644 --- a/gio/glib-compile-schemas.c +++ b/gio/glib-compile-schemas.c @@ -97,9 +97,9 @@ enum_state_add_value (EnumState *state, } value = g_ascii_strtoll (valuestr, &end, 0); - if (*end || state->is_flags ? + if (*end || (state->is_flags ? (value > G_MAXUINT32 || value < 0) : - (value > G_MAXINT32 || value < G_MININT32)) + (value > G_MAXINT32 || value < G_MININT32))) { g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, diff --git a/gio/tests/gschema-compile.c b/gio/tests/gschema-compile.c index 40a396d2f..99b2d1b97 100644 --- a/gio/tests/gschema-compile.c +++ b/gio/tests/gschema-compile.c @@ -86,6 +86,7 @@ static const SchemaTest tests[] = { { "enum", NULL, NULL }, { "enum-with-aliases", NULL, NULL }, { "enum-with-invalid-alias", NULL, "*“banger” is not in enumerated type*" }, + { "enum-with-invalid-value", NULL, "*invalid numeric value*" }, { "enum-with-repeated-alias", NULL, "* already specified*" }, { "enum-with-repeated-nick", NULL, "* already specified*" }, { "enum-with-repeated-value", NULL, "*value='1' already specified*" }, diff --git a/gio/tests/schema-tests/enum-with-invalid-value.gschema.xml b/gio/tests/schema-tests/enum-with-invalid-value.gschema.xml new file mode 100644 index 000000000..02071e070 --- /dev/null +++ b/gio/tests/schema-tests/enum-with-invalid-value.gschema.xml @@ -0,0 +1,10 @@ + + + + + + + + + +