[gnome-builder/gnome-builder-3-20] command-bar: Check if the completion provider fulfills its contract
- From: Matthew Leeds <mwleeds src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/gnome-builder-3-20] command-bar: Check if the completion provider fulfills its contract
- Date: Thu, 9 Jun 2016 17:34:47 +0000 (UTC)
commit c38ca1d89ab763dd41a9848a5fcd5ab61c5f6923
Author: Matthew Leeds <mleeds redhat com>
Date: Tue Jun 7 13:18:42 2016 -0400
command-bar: Check if the completion provider fulfills its contract
Emit a warning if the provided completion is not a prefix of the command
typed by the user, and don't display it as an option. Otherwise we would
read past the end of a character array.
https://bugzilla.gnome.org/show_bug.cgi?id=767369
plugins/command-bar/gb-command-bar.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/plugins/command-bar/gb-command-bar.c b/plugins/command-bar/gb-command-bar.c
index accbc00..47e57a8 100644
--- a/plugins/command-bar/gb-command-bar.c
+++ b/plugins/command-bar/gb-command-bar.c
@@ -436,6 +436,12 @@ gb_command_bar_complete (GbCommandBar *self)
GtkWidget *label;
char *s;
+ if (!g_str_has_prefix (completions[i], current_prefix))
+ {
+ g_warning ("Provided completion does not contain '%s' as a prefix", current_prefix);
+ continue;
+ }
+
label = gtk_label_new ("");
s = g_strdup_printf ("<b>%s</b>%s", current_prefix, completions[i] + strlen (current_prefix));
gtk_label_set_markup (GTK_LABEL (label), s);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]