diff options
Diffstat (limited to 'lib/utils/hooklib.cpp')
| -rw-r--r-- | lib/utils/hooklib.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/utils/hooklib.cpp b/lib/utils/hooklib.cpp index 7c794ef5..f82a9ae5 100644 --- a/lib/utils/hooklib.cpp +++ b/lib/utils/hooklib.cpp @@ -118,18 +118,19 @@ void check_free_space(unsigned setting_MaxCrashReportsSize) void trim_debug_dumps(unsigned setting_MaxCrashReportsSize, const char *exclude_path) { int count = 10; - string worst_dir; while (--count >= 0) { const char *base_dirname = strrchr(exclude_path, '/') + 1; /* never NULL */ /* We exclude our own dump from candidates for deletion (3rd param): */ + char *worst_dir = NULL; double dirsize = get_dirsize_find_largest_dir(DEBUG_DUMPS_DIR, &worst_dir, base_dirname); - if (dirsize / (1024*1024) < setting_MaxCrashReportsSize || worst_dir == "") + if (dirsize / (1024*1024) < setting_MaxCrashReportsSize || !worst_dir) break; - log("size of '%s' >= %u MB, deleting '%s'", DEBUG_DUMPS_DIR, setting_MaxCrashReportsSize, worst_dir.c_str()); - char *d = concat_path_file(DEBUG_DUMPS_DIR, worst_dir.c_str()); + log("size of '%s' >= %u MB, deleting '%s'", DEBUG_DUMPS_DIR, setting_MaxCrashReportsSize, worst_dir); + char *d = concat_path_file(DEBUG_DUMPS_DIR, worst_dir); + free(worst_dir); + worst_dir = NULL; delete_debug_dump_dir(d); free(d); - worst_dir = ""; } } |
