diff options
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -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 |