[gnome-builder] completion: handle null needles
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] completion: handle null needles
- Date: Thu, 14 Jun 2018 01:05:00 +0000 (UTC)
commit ec3bad5c67080c63f7a709cf0a44b4412ca8be65
Author: Christian Hergert <chergert redhat com>
Date: Wed Jun 13 18:04:20 2018 -0700
completion: handle null needles
We used to add checks everywhere for this, but it's easier if we just
give ourselves some protection against str*() functions dereferencing.
src/libide/completion/ide-completion.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/src/libide/completion/ide-completion.c b/src/libide/completion/ide-completion.c
index 4bcc525cb..8ac589185 100644
--- a/src/libide/completion/ide-completion.c
+++ b/src/libide/completion/ide-completion.c
@@ -1629,7 +1629,7 @@ _ide_completion_set_font_description (IdeCompletion *self,
/**
* ide_completion_fuzzy_match:
- * @haystack: the string to be searched.
+ * @haystack: (nullable): the string to be searched.
* @casefold_needle: A g_utf8_casefold() version of the needle.
* @priority: (out) (allow-none): An optional location for the score of the match
*
@@ -1651,6 +1651,9 @@ ide_completion_fuzzy_match (const gchar *haystack,
{
gint real_score = 0;
+ if (haystack == NULL || haystack[0] == 0)
+ return FALSE;
+
for (; *casefold_needle; casefold_needle = g_utf8_next_char (casefold_needle))
{
gunichar ch = g_utf8_get_char (casefold_needle);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]