Skip to content

Commit c3072c6

Browse files
committed
refspec-api: avoid uninitialized field in refspec item
When parse_refspec() function was created at 3eec370 ("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 <[email protected]>
1 parent 60fba4b commit c3072c6

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

refspec.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ static int parse_refspec(struct refspec_item *item, const char *refspec, int fet
4848
size_t rlen = strlen(++rhs);
4949
is_glob = (1 <= rlen && strchr(rhs, '*'));
5050
item->dst = xstrndup(rhs, rlen);
51+
} else {
52+
item->dst = NULL;
5153
}
5254

5355
llen = (rhs ? (rhs - lhs - 1) : strlen(lhs));

0 commit comments

Comments
 (0)