summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-02-15 01:41:09 -0500
committerMatthias Clasen <mclasen@redhat.com>2021-02-15 01:46:00 -0500
commit2f43b8dc49491c1dd73248326722eeb12029d95f (patch)
tree9a0a5e06129987f08951b35b2a3d3e3e7d3adf63
parentd2e074e36b5c3c8def215dbbf56f2507b36f561f (diff)
downloadgtk+-2f43b8dc49491c1dd73248326722eeb12029d95f.tar.gz
imcontext: Improve compose table parsinglenient-compose-parsing
Avoid leaking value in error cases, and actually emit a warning for a missing quote. Pointed out by Peter Bloomfield.
-rw-r--r--gtk/gtkcomposetable.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/gtk/gtkcomposetable.c b/gtk/gtkcomposetable.c
index 3c60cc1886..09cf7b8e8f 100644
--- a/gtk/gtkcomposetable.c
+++ b/gtk/gtkcomposetable.c
@@ -82,30 +82,34 @@ parse_compose_value (GtkComposeData *compose_data,
gunichar ch;
char *endp;
+ value = g_string_new ("");
+
if (val[0] != '"')
{
g_warning ("Only strings supported after ':': %s: %s", val, line);
goto fail;
}
- value = g_string_new ("");
-
p = val + 1;
while (*p)
{
- if (*p == '\0')
- {
- g_warning ("Missing closing '\"': %s: %s", val, line);
- goto fail;
- }
- else if (*p == '\"')
+ if (*p == '\"')
{
p++;
while (*p && g_ascii_isspace (*p))
p++;
+
if (*p != '\0' && *p != '#')
g_warning ("Ignoring keysym after string: %s: %s", val, line);
- break;
+
+ compose_data->value = g_string_free (value, FALSE);
+ return TRUE;
+ }
+
+ if (p[1] == '\0')
+ {
+ g_warning ("Missing closing '\"': %s: %s", val, line);
+ goto fail;
}
else if (*p == '\\')
{
@@ -155,11 +159,9 @@ parse_compose_value (GtkComposeData *compose_data,
}
}
- compose_data->value = g_string_free (value, FALSE);
-
- return TRUE;
-
fail:
+ g_string_free (value, TRUE);
+
return FALSE;
}