mirror of
https://github.com/opentx/opentx.git
synced 2025-07-24 16:55:20 +03:00
Re #2987: read_file_system_list() return value memory leak fixed
This commit is contained in:
parent
d38cf06b07
commit
ee4ea18a3e
3 changed files with 21 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue