[Xfce4-commits] <exo:master> Protect strstr against null values, probably the crash in bug #3847.
Nick Schermer
nick at xfce.org
Thu Aug 27 20:00:02 CEST 2009
Updating branch refs/heads/master
to 59594bc3b42d4ba7acb675db54819707fa7c1bcb (commit)
from 54edd5fd5a501db44084a29eccde2851a82302b9 (commit)
commit 59594bc3b42d4ba7acb675db54819707fa7c1bcb
Author: Nick Schermer <nick at xfce.org>
Date: Thu Aug 27 18:09:54 2009 +0200
Protect strstr against null values, probably the crash in bug #3847.
exo-desktop-item-edit/exo-die-desktop-model.c | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/exo-desktop-item-edit/exo-die-desktop-model.c b/exo-desktop-item-edit/exo-die-desktop-model.c
index 225db5a..2b50b57 100644
--- a/exo-desktop-item-edit/exo-die-desktop-model.c
+++ b/exo-desktop-item-edit/exo-die-desktop-model.c
@@ -702,11 +702,15 @@ exo_die_desktop_model_match_func (GtkEntryCompletion *completion,
desktop_item = g_slist_nth_data (iter->user_data, 0);
/* check if the name matches */
- normalized = g_utf8_normalize (desktop_item->name, -1, G_NORMALIZE_ALL);
- casefolded = g_utf8_casefold (normalized, -1);
- matches = (strstr (casefolded, key) != NULL);
- g_free (casefolded);
- g_free (normalized);
+ if (G_LIKELY (desktop_item->name != NULL))
+ {
+ normalized = g_utf8_normalize (desktop_item->name, -1, G_NORMALIZE_ALL);
+ casefolded = g_utf8_casefold (normalized, -1);
+ if (G_LIKELY (casefolded != NULL && key != NULL))
+ matches = (strstr (casefolded, key) != NULL);
+ g_free (casefolded);
+ g_free (normalized);
+ }
/* check if no hit yet */
if (G_LIKELY (!matches && desktop_item->comment != NULL))
@@ -714,7 +718,8 @@ exo_die_desktop_model_match_func (GtkEntryCompletion *completion,
/* also check the comment then */
normalized = g_utf8_normalize (desktop_item->comment, -1, G_NORMALIZE_ALL);
casefolded = g_utf8_casefold (normalized, -1);
- matches = (strstr (casefolded, key) != NULL);
+ if (G_LIKELY (casefolded != NULL && key != NULL))
+ matches = (strstr (casefolded, key) != NULL);
g_free (casefolded);
g_free (normalized);
}
More information about the Xfce4-commits
mailing list