diff --git a/companion/src/mountlist.cpp b/companion/src/mountlist.cpp index 5c1408c9e..e041a5fe0 100644 --- a/companion/src/mountlist.cpp +++ b/companion/src/mountlist.cpp @@ -922,4 +922,19 @@ read_file_system_list (bool need_fs_type) } } +void free_file_system_list(struct mount_entry * mount_list) +{ + struct mount_entry * me; + while (mount_list) + { + me = mount_list->me_next; + free (mount_list->me_devname); + free (mount_list->me_mountdir); + if (mount_list->me_type_malloced) + free (mount_list->me_type); + free (mount_list); + mount_list = me; + } +} + #endif diff --git a/companion/src/mountlist.h b/companion/src/mountlist.h index 8d8c3cbf4..a6caad729 100644 --- a/companion/src/mountlist.h +++ b/companion/src/mountlist.h @@ -49,4 +49,6 @@ struct mount_entry struct mount_entry *read_file_system_list (bool need_fs_type); +void free_file_system_list(struct mount_entry * mount_list); + #endif diff --git a/companion/src/radiointerface.cpp b/companion/src/radiointerface.cpp index 47b37668e..1626523df 100644 --- a/companion/src/radiointerface.cpp +++ b/companion/src/radiointerface.cpp @@ -411,7 +411,8 @@ QString findMassstoragePath(const QString &filename) } #else struct mount_entry *entry; - entry = read_file_system_list(true); + struct mount_entry *firstEntry; + firstEntry = entry = read_file_system_list(true); while (entry != NULL) { if (!drives.contains(entry->me_devname)) { drives.append(entry->me_devname); @@ -426,11 +427,13 @@ QString findMassstoragePath(const QString &filename) #else if (QFile::exists(eepromfile)) { #endif + free_file_system_list(firstEntry); return eepromfile; } } entry = entry->me_next; } + free_file_system_list(firstEntry); #endif return QString();