diff --git a/Src/utils.c b/Src/utils.c index 914e30c..1eb8c71 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -5058,23 +5058,23 @@ ztrlenend(char const *s, char const *eptr) #endif /* MULTIBYTE_SUPPORT */ /* Subtract two pointers in a metafied string. */ /**/ mod_export int ztrsub(char const *t, char const *s) { int l = t - s; while (s != t) { - if (*s++ == Meta) { + if (*s++ == Meta || (s != t && *s++ == Meta)) { #ifdef DEBUG if (! *s || s == t) fprintf(stderr, "BUG: substring ends in the middle of a metachar in ztrsub()\n"); else #endif s++; l--; } } return l; }