diff --git a/lib-src/etags.c b/lib-src/etags.c index 22e6d35ae10..b838d90b636 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c @@ -4714,9 +4714,10 @@ relative_filename (file, dir) while (*fp++ == *dp++) continue; fp--, dp--; /* back to the first differing char */ - do /* look at the equal chars until '/' */ + do { /* look at the equal chars until '/' */ + if (fp == abs) return abs; /* first char differs, give up */ fp--, dp--; - while (*fp != '/'); + } while (*fp != '/'); /* Build a sequence of "../" strings for the resulting relative file name. */ i = 0;