diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2014-06-11 00:06:44 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-06-11 00:06:44 +0200 |
commit | f9a97667945a87abfca50e153a7d2fdf5c4319a8 (patch) | |
tree | 83db2d6e327e2c2636489a2fef53b3f07dbfe041 | |
parent | 7064cdafbd25f66de016467b381d9f4474fba40a (diff) | |
download | libgit2-f9a97667945a87abfca50e153a7d2fdf5c4319a8.tar.gz |
revwalk: more sensible array handlingcmn/revwalk-array-fix
Instead of using a sentinel empty value to detect the last commit, let's
check for when we get a NULL from popping the stack, which lets us know
when we're done.
The current code causes us to read uninitialized data, although only on
RHEL/CentOS 6 in release mode. This is a readability win overall.
-rw-r--r-- | src/revwalk.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/revwalk.c b/src/revwalk.c index 7aedd1f44..530c9705e 100644 --- a/src/revwalk.c +++ b/src/revwalk.c @@ -48,7 +48,7 @@ static int mark_uninteresting(git_revwalk *walk, git_commit_list_node *commit) assert(commit); - git_array_alloc(pending); + git_array_init_to_size(pending, 2); GITERR_CHECK_ARRAY(pending); do { @@ -67,7 +67,7 @@ static int mark_uninteresting(git_revwalk *walk, git_commit_list_node *commit) tmp = git_array_pop(pending); commit = tmp ? *tmp : NULL; - } while (git_array_size(pending) > 0); + } while (commit != NULL); git_array_clear(pending); |