Skip to content

Commit f08a5d4

Browse files
bmwillgitster
authored andcommitted
remote-curl: create copy of the service name
Make a copy of the service name being requested instead of relying on the buffer pointed to by the passed in 'const char *' to remain unchanged. Currently, all service names are string constants, but a subsequent patch will introduce service names from external sources. Signed-off-by: Brandon Williams <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f1f4d8a commit f08a5d4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

remote-curl.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ static int set_option(const char *name, const char *value)
165165
}
166166

167167
struct discovery {
168-
const char *service;
168+
char *service;
169169
char *buf_alloc;
170170
char *buf;
171171
size_t len;
@@ -257,6 +257,7 @@ static void free_discovery(struct discovery *d)
257257
free(d->shallow.oid);
258258
free(d->buf_alloc);
259259
free_refs(d->refs);
260+
free(d->service);
260261
free(d);
261262
}
262263
}
@@ -343,7 +344,7 @@ static struct discovery *discover_refs(const char *service, int for_push)
343344
warning(_("redirecting to %s"), url.buf);
344345

345346
last= xcalloc(1, sizeof(*last_discovery));
346-
last->service = service;
347+
last->service = xstrdup(service);
347348
last->buf_alloc = strbuf_detach(&buffer, &last->len);
348349
last->buf = last->buf_alloc;
349350

0 commit comments

Comments
 (0)