]> git.ozlabs.org Git - ccan/blobdiff - tools/tools.c
tdb2: traversal test.
[ccan] / tools / tools.c
index b7beda72b9c5b6cf0a5ec8beffb34d535887b6a3..a4944bd1f8988b43cf63e63ac42460a0d1643529 100644 (file)
@@ -28,7 +28,7 @@ char *talloc_basename(const void *ctx, const char *dir)
        char *p = strrchr(dir, '/');
 
        if (!p)
-               return (char *)dir;
+               return talloc_strdup(ctx, dir);
        return talloc_strdup(ctx, p+1);
 }
 
@@ -204,9 +204,9 @@ char *temp_dir(const void *ctx)
                        err(1, "mkdir %s failed", tmpdir);
                }
                talloc_set_destructor(tmpdir, unlink_all);
+               if (tools_verbose)
+                       printf("Created temporary directory %s\n", tmpdir);
        }
-       if (tools_verbose)
-               printf("Created temporary directory %s\n", tmpdir);
        return tmpdir;
 }