]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Fix minor memory leaks
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 7 Jan 2012 15:01:45 +0000 (16:01 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sat, 7 Jan 2012 15:01:45 +0000 (16:01 +0100)
ccache.c
manifest.c
util.c

index a8a050e63c008715a57c763ecf0e22cab84666dc..915138af05d97bd791ce1ce06c15162bab56a1e0 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -857,7 +857,9 @@ calculate_common_hash(struct args *args, struct mdfour *hash)
         * behave differently depending on the real name.
         */
        hash_delimiter(hash, "cc_name");
-       hash_string(hash, basename(args->argv[0]));
+       p = basename(args->argv[0]);
+       hash_string(hash, p);
+       free(p);
 
        /* Possibly hash the current working directory. */
        if (getenv("CCACHE_HASHDIR")) {
index fcc163d659624601fea536171e9558940c3c14e6..335874b78d1b6a4aae05bedac2d5de2523502076 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009-2010 Joel Rosdahl
+ * Copyright (C) 2009-2010, 2012 Joel Rosdahl
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the Free
@@ -133,6 +133,7 @@ free_manifest(struct manifest *mf)
                free(mf->objects[i].file_info_indexes);
        }
        free(mf->objects);
+       free(mf);
 }
 
 #define READ_INT(size, var) \
diff --git a/util.c b/util.c
index 1be5f0811af01450b845e61c304a73d5af336f6c..3086b2c62ac11fd8dda24bdd9f7000eb17a2137d 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2002 Andrew Tridgell
- * Copyright (C) 2009-2011 Joel Rosdahl
+ * Copyright (C) 2009-2012 Joel Rosdahl
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the Free
@@ -1101,15 +1101,19 @@ x_unlink(const char *path)
         * file. We don't care if the temp file is trashed, so it's always safe to
         * unlink it first.
         */
-       const char* tmp_name = format("%s.%s.rmXXXXXX", path, tmp_string());
+       char* tmp_name = format("%s.%s.rmXXXXXX", path, tmp_string());
+       int result = 0;
        cc_log("Unlink %s via %s", path, tmp_name);
        if (x_rename(path, tmp_name) == -1) {
-               return -1;
+               result = -1;
+               goto out;
        }
        if (unlink(tmp_name) == -1) {
-               return -1;
+               result = -1;
        }
-       return 0;
+out:
+       free(tmp_name);
+       return result;
 }
 
 #ifndef _WIN32