aboutsummaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@osdl.org>2005-09-14 13:41:24 -0700
committerJunio C Hamano <junkio@cox.net>2005-09-14 13:57:34 -0700
commit705a7148ba1bb9597b1837b7f64a0dcb67f1ad0c (patch)
treecd8f4b0ba024c434e5e76ef7168f9c4342247bd5 /diff.c
parentc80522e30fdc190f8c8c7fc983bbe040a1b03e93 (diff)
downloadgit-705a7148ba1bb9597b1837b7f64a0dcb67f1ad0c.tar.gz
git-705a7148ba1bb9597b1837b7f64a0dcb67f1ad0c.tar.xz
[PATCH] Fix alloc_filespec() initialization
This simplifies and fixes the initialization of a "diff_filespec" when allocated. The old code would not initialize "sha1_valid". Noticed by valgrind. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/diff.c b/diff.c
index f8e3cbf1a..1059049fb 100644
--- a/diff.c
+++ b/diff.c
@@ -214,14 +214,10 @@ struct diff_filespec *alloc_filespec(const char *path)
{
int namelen = strlen(path);
struct diff_filespec *spec = xmalloc(sizeof(*spec) + namelen + 1);
+
+ memset(spec, 0, sizeof(*spec));
spec->path = (char *)(spec + 1);
- strcpy(spec->path, path);
- spec->should_free = spec->should_munmap = 0;
- spec->xfrm_flags = 0;
- spec->size = 0;
- spec->data = NULL;
- spec->mode = 0;
- memset(spec->sha1, 0, 20);
+ memcpy(spec->path, path, namelen+1);
return spec;
}