diff options
| author | Patrick Steinhardt <ps@pks.im> | 2019-07-04 11:41:21 +0200 |
|---|---|---|
| committer | Patrick Steinhardt <ps@pks.im> | 2019-07-04 11:41:21 +0200 |
| commit | 1bbec26d2bbe1852ffb87d0bf9a3a1cabc4df53f (patch) | |
| tree | 0789f9abf42fd03d7659252fd59bec13a1e87759 /src/attr_file.c | |
| parent | 18a6d9f3a82d2363ed45713a47f48ac8f383bb41 (diff) | |
| download | libgit2-1bbec26d2bbe1852ffb87d0bf9a3a1cabc4df53f.tar.gz | |
attr_file: completely initialize attribute sessions
The function `git_attr_session__init` is currently only initializing
setting up the attribute's session key by incrementing the repo-global
key by one. Most notably, all other members of the `git_attr_session`
struct are not getting initialized at all. So if one is to allocate a
session on the stack and then calls `git_attr_session__init`, the
session will still not be fully initialized. We have fared just fine
with that until now as all users of the function have allocated the
session structure as part of bigger structs with `calloc`, and thus its
contents have been zero-initialized implicitly already.
Fix this by explicitly zeroing out the session to enable allocation of
sessions on the stack.
Diffstat (limited to 'src/attr_file.c')
| -rw-r--r-- | src/attr_file.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/attr_file.c b/src/attr_file.c index edcfbdad5..55838370c 100644 --- a/src/attr_file.c +++ b/src/attr_file.c @@ -919,6 +919,7 @@ int git_attr_session__init(git_attr_session *session, git_repository *repo) { assert(repo); + memset(session, 0, sizeof(*session)); session->key = git_atomic_inc(&repo->attr_session_key); return 0; |
