diff options
author | Pierre Habouzit <madcoder@debian.org> | 2007-09-16 00:32:36 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-09-18 17:42:17 -0700 |
commit | 182af8343c307436bb5364309aa6d4d46fa5911d (patch) | |
tree | 154c50047e12595027a0d61f54bfdd6ecd2305a5 /http-push.c | |
parent | 39bd2eb56af89d43a08ba54699d9a1849ab57b39 (diff) | |
download | git-182af8343c307436bb5364309aa6d4d46fa5911d.tar.gz |
Use xmemdupz() in many places.
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'http-push.c')
-rw-r--r-- | http-push.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/http-push.c b/http-push.c index 7c3720f602..276e1eb1d9 100644 --- a/http-push.c +++ b/http-push.c @@ -1271,10 +1271,7 @@ xml_cdata(void *userData, const XML_Char *s, int len) { struct xml_ctx *ctx = (struct xml_ctx *)userData; free(ctx->cdata); - ctx->cdata = xmalloc(len + 1); - /* NB: 's' is not null-terminated, can not use strlcpy here */ - memcpy(ctx->cdata, s, len); - ctx->cdata[len] = '\0'; + ctx->cdata = xmemdupz(s, len); } static struct remote_lock *lock_remote(const char *path, long timeout) @@ -2172,9 +2169,7 @@ static void fetch_symref(const char *path, char **symref, unsigned char *sha1) /* If it's a symref, set the refname; otherwise try for a sha1 */ if (!prefixcmp((char *)buffer.buffer, "ref: ")) { - *symref = xmalloc(buffer.posn - 5); - memcpy(*symref, (char *)buffer.buffer + 5, buffer.posn - 6); - (*symref)[buffer.posn - 6] = '\0'; + *symref = xmemdupz((char *)buffer.buffer + 5, buffer.posn - 6); } else { get_sha1_hex(buffer.buffer, sha1); } |