diff options
author | Colin Walters <walters@verbum.org> | 2017-07-31 12:22:16 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2017-08-07 16:10:08 +0000 |
commit | 48f8f329211fd6647b0c9bd0b72d494e8701a0fb (patch) | |
tree | bc6268c31da42e9bdeed39ffae8e5e29b3b1f0b9 /src/ostree/ot-builtin-pull.c | |
parent | 8eec337feee95d76f14f6e1b39e0b08673e40c22 (diff) | |
download | ostree-48f8f329211fd6647b0c9bd0b72d494e8701a0fb.tar.gz |
bin/pull: Fix @ override syntax when pulling multiple refs
Coverity spotted an infloop here since we were incrementing `i++`
instead of `j++`. But adding a test revealed other bugs - we need
to keep the arrays in sync.
Coverity CID: 1452204
Closes: #1041
Approved by: pwithnall
Diffstat (limited to 'src/ostree/ot-builtin-pull.c')
-rw-r--r-- | src/ostree/ot-builtin-pull.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/ostree/ot-builtin-pull.c b/src/ostree/ot-builtin-pull.c index 36e99b3a..b07ce90b 100644 --- a/src/ostree/ot-builtin-pull.c +++ b/src/ostree/ot-builtin-pull.c @@ -209,11 +209,13 @@ ostree_builtin_pull (int argc, char **argv, GCancellable *cancellable, GError ** goto out; if (!override_commit_ids) - override_commit_ids = g_ptr_array_new_with_free_func (g_free); + { + override_commit_ids = g_ptr_array_new_with_free_func (g_free); - /* Backfill */ - for (j = 2; j < i; i++) - g_ptr_array_add (override_commit_ids, g_strdup ("")); + /* Backfill */ + for (j = 2; j < i; j++) + g_ptr_array_add (override_commit_ids, g_strdup ("")); + } g_ptr_array_add (override_commit_ids, g_strdup (override_commit_id)); g_ptr_array_add (refs_to_fetch, g_strndup (argv[i], at - argv[i])); @@ -221,6 +223,8 @@ ostree_builtin_pull (int argc, char **argv, GCancellable *cancellable, GError ** else { g_ptr_array_add (refs_to_fetch, g_strdup (argv[i])); + if (override_commit_ids) + g_ptr_array_add (override_commit_ids, g_strdup ("")); } } |