summaryrefslogtreecommitdiffstats
path: root/path.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-07-21 21:35:39 +0200
committerJunio C Hamano <gitster@pobox.com>2014-07-21 21:35:39 +0200
commit9ab08822556c49a7856dadd0e9a42f9ec2aaf850 (patch)
treef52f20367d13f2078fe6199e230322c899b9308d /path.c
parentNinth batch for 2.1 (diff)
parentuse xmemdupz() to allocate copies of strings given by start and length (diff)
downloadgit-9ab08822556c49a7856dadd0e9a42f9ec2aaf850.tar.xz
git-9ab08822556c49a7856dadd0e9a42f9ec2aaf850.zip
Merge branch 'maint'
* maint: use xmemdupz() to allocate copies of strings given by start and length use xcalloc() to allocate zero-initialized memory
Diffstat (limited to 'path.c')
-rw-r--r--path.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/path.c b/path.c
index bc804a31b3..25c3b8ba7e 100644
--- a/path.c
+++ b/path.c
@@ -249,9 +249,7 @@ int validate_headref(const char *path)
static struct passwd *getpw_str(const char *username, size_t len)
{
struct passwd *pw;
- char *username_z = xmalloc(len + 1);
- memcpy(username_z, username, len);
- username_z[len] = '\0';
+ char *username_z = xmemdupz(username, len);
pw = getpwnam(username_z);
free(username_z);
return pw;