From c50ead13dd8c1ed8819dfb922d14039ecfc5a9d8 Mon Sep 17 00:00:00 2001 From: Yevgen Muntyan <17531749+muntyan@users.noreply.github.com> Date: Sun, 6 Aug 2006 22:44:04 -0500 Subject: [PATCH] Do not crash in eggregex --- moo/mooedit/mootextfind.c | 2 +- moo/mooutils/eggregex.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/moo/mooedit/mootextfind.c b/moo/mooedit/mootextfind.c index 4b1135be..4dc4e018 100644 --- a/moo/mooedit/mootextfind.c +++ b/moo/mooedit/mootextfind.c @@ -594,7 +594,7 @@ EggRegex* moo_find_get_regex (MooFind *find) { g_return_val_if_fail (MOO_IS_FIND (find), NULL); - return find->regex ? egg_regex_ref (find->regex) : NULL; + return egg_regex_ref (find->regex); } diff --git a/moo/mooutils/eggregex.c b/moo/mooutils/eggregex.c index 3e4f7315..1b098ac6 100644 --- a/moo/mooutils/eggregex.c +++ b/moo/mooutils/eggregex.c @@ -80,6 +80,7 @@ regex_new (pcre *re, EggRegex *regex = g_new0 (EggRegex, 1); gint capture_count; + regex->ref_count = 1; regex->regex = re; regex->pattern = g_strdup (pattern); regex->string_len = -1; /* not set yet */ @@ -312,6 +313,7 @@ egg_regex_clear (EggRegex *regex) * delimiter offsets stored. Free up those guys as well. */ if (regex->delims != NULL) g_slist_free (regex->delims); + regex->delims = NULL; } /** @@ -1308,7 +1310,7 @@ egg_regex_split_next_full (EggRegex *regex, if (regex->delims != NULL) { token = regex->delims->data; - regex->delims = g_slist_remove (regex->delims, token); + regex->delims = g_slist_delete_link (regex->delims, regex->delims); return token; }