summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--commit.h2
-rw-r--r--log-tree.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/commit.h b/commit.h
index f3d2f57a89..99b9e78209 100644
--- a/commit.h
+++ b/commit.h
@@ -30,7 +30,7 @@ extern const char *commit_type;
struct name_decoration {
struct name_decoration *next;
int type;
- char name[1];
+ char name[FLEX_ARRAY];
};
enum decoration_type {
diff --git a/log-tree.c b/log-tree.c
index 2adf82ba02..de760db1a6 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -77,7 +77,7 @@ int parse_decorate_color_config(const char *var, const int ofs, const char *valu
void add_name_decoration(enum decoration_type type, const char *name, struct object *obj)
{
int nlen = strlen(name);
- struct name_decoration *res = xmalloc(sizeof(struct name_decoration) + nlen);
+ struct name_decoration *res = xmalloc(sizeof(*res) + nlen + 1);
memcpy(res->name, name, nlen + 1);
res->type = type;
res->next = add_decoration(&name_decoration, obj, res);