diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c index c904ac3101..00afe89317 100644 --- a/builtin-for-each-ref.c +++ b/builtin-for-each-ref.c @@ -113,7 +113,7 @@ static int parse_atom(const char *atom, const char *ep) * table. */ const char *formatp = strchr(sp, ':'); - if (!formatp) + if (!formatp || ep < formatp) formatp = ep; if (len == formatp - sp && !memcmp(valid_atom[i].name, sp, len)) break;