aboutsummaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/autocomplete.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/tools/autocomplete.c b/src/tools/autocomplete.c
index efff6ee0..842ec22a 100644
--- a/src/tools/autocomplete.c
+++ b/src/tools/autocomplete.c
@@ -115,19 +115,21 @@ autocomplete_add(Autocomplete ac, const char *item)
void
autocomplete_remove(Autocomplete ac, const char * const item)
{
- GSList *curr = g_slist_find_custom(ac->items, item, (GCompareFunc)strcmp);
+ if (ac != NULL) {
+ GSList *curr = g_slist_find_custom(ac->items, item, (GCompareFunc)strcmp);
- if (!curr) {
- return;
- }
+ if (!curr) {
+ return;
+ }
- // reset last found if it points to the item to be removed
- if (ac->last_found == curr) {
- ac->last_found = NULL;
- }
+ // reset last found if it points to the item to be removed
+ if (ac->last_found == curr) {
+ ac->last_found = NULL;
+ }
- free(curr->data);
- ac->items = g_slist_delete_link(ac->items, curr);
+ free(curr->data);
+ ac->items = g_slist_delete_link(ac->items, curr);
+ }
return;
}