X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=src%2Flaunch.c;h=f9d8329f93d381a2badf554e6f54ca4f8fff153c;hb=0dc1f8e7aeb390e72125f459930850b8050318df;hp=8bc96fd6efe05eff3bfee905a5312400554a3618;hpb=21aac863e29eca5552c4ae1645306e966f11c1d8;p=libguestfs.git diff --git a/src/launch.c b/src/launch.c index 8bc96fd..f9d8329 100644 --- a/src/launch.c +++ b/src/launch.c @@ -249,10 +249,7 @@ guestfs__launch (guestfs_h *g) /* Make the temporary directory. */ if (!g->tmpdir) { - const char *tmpdir = guestfs___tmpdir (); - char dir_template[strlen (tmpdir) + 32]; - sprintf (dir_template, "%s/libguestfsXXXXXX", tmpdir); - + TMP_TEMPLATE_ON_STACK (dir_template); g->tmpdir = safe_strdup (g, dir_template); if (mkdtemp (g->tmpdir) == NULL) { perrorf (g, _("%s: cannot create temporary directory"), dir_template); @@ -511,6 +508,8 @@ guestfs__launch (guestfs_h *g) kernel = NULL; free (initrd); initrd = NULL; + free (appliance); + appliance = NULL; /* Fork the recovery process off which will kill qemu if the parent * process fails to do so (eg. if the parent segfaults). @@ -647,8 +646,11 @@ guestfs__launch (guestfs_h *g) return -1; } +/* Return the location of the tmpdir (eg. "/tmp") and allow users + * to override it at runtime using $TMPDIR. + */ const char * -guestfs___tmpdir (void) +guestfs_tmpdir (void) { const char *tmpdir;