]> granicus.if.org Git - git/commitdiff
refspec-api: avoid uninitialized field in refspec item
authorJunio C Hamano <gitster@pobox.com>
Fri, 1 Jun 2018 02:33:19 +0000 (11:33 +0900)
committerJunio C Hamano <gitster@pobox.com>
Fri, 1 Jun 2018 02:46:07 +0000 (11:46 +0900)
When parse_refspec() function was created at 3eec3700 ("refspec:
factor out parsing a single refspec", 2018-05-16) to take a caller
supplied piece of memory to fill parsed refspec_item, it forgot that
a refspec without colon must set item->dst to NULL to let the users
of refspec know that the result of the fetch does not get stored in
an ref on our side.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
refspec.c

index 97e76e8b1d953c9f2d7b99c906aef17fd375d7f5..6e45365a23563b3cfd62f025fc74ec7980382ac7 100644 (file)
--- a/refspec.c
+++ b/refspec.c
@@ -48,6 +48,8 @@ static int parse_refspec(struct refspec_item *item, const char *refspec, int fet
                size_t rlen = strlen(++rhs);
                is_glob = (1 <= rlen && strchr(rhs, '*'));
                item->dst = xstrndup(rhs, rlen);
+       } else {
+               item->dst = NULL;
        }
 
        llen = (rhs ? (rhs - lhs - 1) : strlen(lhs));