summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 562cefb)
raw | patch | inline | side by side (parent: 562cefb)
author | Junio C Hamano <junkio@cox.net> | |
Mon, 4 Dec 2006 10:11:39 +0000 (02:11 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Mon, 4 Dec 2006 22:24:28 +0000 (14:24 -0800) |
The structure that ends with a flexible array member (or 0
length array with older GCC) "char name[FLEX_ARRAY]" is
allocated on the stack and we use it after clearing its entire
size with memset. That does not guarantee that "name" is
properly NUL terminated as we intended on platforms with more
forgiving structure alignment requirements.
Reported breakage on m68k by Roman Zippel.
Signed-off-by: Junio C Hamano <junkio@cox.net>
length array with older GCC) "char name[FLEX_ARRAY]" is
allocated on the stack and we use it after clearing its entire
size with memset. That does not guarantee that "name" is
properly NUL terminated as we intended on platforms with more
forgiving structure alignment requirements.
Reported breakage on m68k by Roman Zippel.
Signed-off-by: Junio C Hamano <junkio@cox.net>
unpack-trees.c | patch | blob | history |
diff --git a/unpack-trees.c b/unpack-trees.c
index 7cfd628d8e1c576115cb934e72138535fb7d2db3..47aa804a86d735d0fa84718708877ace962094bf 100644 (file)
--- a/unpack-trees.c
+++ b/unpack-trees.c
int i;
struct object_list *posn = trees;
struct tree_entry_list df_conflict_list;
- struct cache_entry df_conflict_entry;
+ static struct cache_entry *dfc;
memset(&df_conflict_list, 0, sizeof(df_conflict_list));
df_conflict_list.next = &df_conflict_list;
state.refresh_cache = 1;
o->merge_size = len;
- memset(&df_conflict_entry, 0, sizeof(df_conflict_entry));
- o->df_conflict_entry = &df_conflict_entry;
+
+ if (!dfc)
+ dfc = xcalloc(1, sizeof(struct cache_entry) + 1);
+ o->df_conflict_entry = dfc;
if (len) {
posns = xmalloc(len * sizeof(struct tree_entry_list *));