refspec-api: avoid uninitialized field in refspec item
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>
Junio C Hamano committed
Jun 1, 2018 at 11:33 UTC
c3072c6e4db9130d0920bc8034f197624874de3d
1 file changed
+2
refspec.c
+2
@@ -48,6 +48,8 @@ static int parse_refspec(struct refspec_item *item, const char *refspec, int fet
48
size_t rlen = strlen(++rhs);
49
is_glob = (1 <= rlen && strchr(rhs, '*'));
50
item->dst = xstrndup(rhs, rlen);
51
+ } else {
52
+ item->dst = NULL;
53
}
54
55
llen = (rhs ? (rhs - lhs - 1) : strlen(lhs));