diff options
| author | Carlos Martín Nieto <carlos@cmartin.tk> | 2012-06-20 01:41:30 +0200 |
|---|---|---|
| committer | Carlos Martín Nieto <carlos@cmartin.tk> | 2012-06-20 01:41:30 +0200 |
| commit | c06e0003944cb14b8236d994794c2eabb8fad1d4 (patch) | |
| tree | e169021b4bfb2ac71bf447056eb5ccd568be436e /src/odb.c | |
| parent | cdca82c7842ade2074f37be22f2251d6a9040a9d (diff) | |
| download | libgit2-c06e0003944cb14b8236d994794c2eabb8fad1d4.tar.gz | |
odb: don't leak when detecting id ambiguity
If we find several objects with the same prefix, we need to free the
memory where we stored the earlier object. Keep track of the raw.data
pointer across read_prefix calls and free it if we find another
object.
Diffstat (limited to 'src/odb.c')
| -rw-r--r-- | src/odb.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -559,6 +559,7 @@ int git_odb_read_prefix( int error = GIT_ENOTFOUND; git_oid found_full_oid = {{0}}; git_rawobj raw; + void *data = NULL; bool found = false; assert(out && db); @@ -588,6 +589,8 @@ int git_odb_read_prefix( if (error) return error; + git__free(data); + data = raw.data; if (found && git_oid_cmp(&full_oid, &found_full_oid)) return git_odb__error_ambiguous("multiple matches for prefix"); found_full_oid = full_oid; |
