lib/repo: Move alloca() outside of loop
authorColin Walters <walters@verbum.org>
Thu, 21 Sep 2017 15:00:09 +0000 (11:00 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Thu, 21 Sep 2017 15:37:48 +0000 (15:37 +0000)
Just noticed this while looking at the code for a different issue.

Closes: #1201
Approved by: jlebon

src/libostree/ostree-repo.c

index 0056d8056eb2b899f54c2a931c93bef4f70041e0..e04a1b6aa11b14bdc8a980c1f5d97981ca3d3c16 100644 (file)
@@ -5179,11 +5179,11 @@ _ostree_repo_allocate_tmpdir (int tmpdir_dfd,
       ret_tmpdir.initialized = TRUE;
     }
 
+  const char *tmpdir_name_template = glnx_strjoina (tmpdir_prefix, "XXXXXX");
   while (!ret_tmpdir.initialized)
     {
       g_auto(GLnxTmpDir) new_tmpdir = { 0, };
       /* No existing tmpdir found, create a new */
-      const char *tmpdir_name_template = glnx_strjoina (tmpdir_prefix, "XXXXXX");
       if (!glnx_mkdtempat (tmpdir_dfd, tmpdir_name_template, 0755,
                            &new_tmpdir, error))
         return FALSE;