diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2004-10-29 11:12:01 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2004-10-29 11:12:01 +0000 |
commit | 7367d21158dcdedb865e11785b94212372608326 (patch) | |
tree | c30d9eae4c7110311786ff547002c94d2194824a /src | |
parent | 1b4467b10894fd082ac221cd74d0dfe3a3bef5ea (diff) | |
download | anubis-7367d21158dcdedb865e11785b94212372608326.tar.gz anubis-7367d21158dcdedb865e11785b94212372608326.tar.bz2 |
(anubis_regex_replace): Fixed coredump
Diffstat (limited to 'src')
-rw-r--r-- | src/regex.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/regex.c b/src/regex.c index bba1b45..e12ea19 100644 --- a/src/regex.c +++ b/src/regex.c @@ -171,22 +171,38 @@ anubis_regex_replace (RC_REGEX * re, char *line, char *repl) { char *q; - alloc = 0; - p = repl; - plen = strlen (p); q = strstr (line + off, anubis_regex_source (re)); - so = (q - (line + off)); - eo = so + strlen (anubis_regex_source (re)); + if (q) + { + alloc = 0; + p = repl; + so = (q - (line + off)); + eo = so + strlen (anubis_regex_source (re)); + } + else + { + char *x[2]; + + x[0] = line + off; + x[1] = NULL; + + alloc = 1; + p = substitute (repl, x); + + so = 0; + eo = strlen (line + off); + } } else { alloc = 1; p = substitute (repl, refv); - plen = strlen (p); xfree_pptr (refv); } + plen = strlen (p); + savep = newstr; newlen = strlen (line) - (eo - so) + plen + 1; newstr = xmalloc (newlen); |