forked from osmocom/wireshark
wslua: fix memleak in Dir.remove_all on error path
While at it, use g_build_filename. Found by Clang Static Analyzer. Change-Id: I5c50f50abb8c16a553586c548ccd1ae6c3cdd8c1 Reviewed-on: https://code.wireshark.org/review/27439 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
d834299472
commit
a729c0f173
|
@ -118,18 +118,17 @@ static int delete_directory(const char *directory) {
|
||||||
/* delete all contents of directory */
|
/* delete all contents of directory */
|
||||||
if ((dir = ws_dir_open(directory, 0, NULL)) != NULL) {
|
if ((dir = ws_dir_open(directory, 0, NULL)) != NULL) {
|
||||||
while ((file = ws_dir_read_name(dir)) != NULL) {
|
while ((file = ws_dir_read_name(dir)) != NULL) {
|
||||||
filename = g_strdup_printf ("%s%s%s", directory, G_DIR_SEPARATOR_S,
|
filename = g_build_filename(directory, ws_dir_get_name(file), NULL);
|
||||||
ws_dir_get_name(file));
|
|
||||||
if (test_for_directory(filename) != EISDIR) {
|
if (test_for_directory(filename) != EISDIR) {
|
||||||
ret = ws_remove(filename);
|
ret = ws_remove(filename);
|
||||||
} else {
|
} else {
|
||||||
/* recurse */
|
/* recurse */
|
||||||
ret = delete_directory (filename);
|
ret = delete_directory (filename);
|
||||||
}
|
}
|
||||||
|
g_free(filename);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
g_free (filename);
|
|
||||||
}
|
}
|
||||||
ws_dir_close(dir);
|
ws_dir_close(dir);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue