mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 13:10:19 +00:00
Make sure memory for default_dive_computer_device is allocated
When calling gtk-gui.c:set_default_dive_computer_device(), first free memory at default_dive_computer_device and then use strdup(). This fixed a case, where after selecting a device for the first time in the "Download" dialog, then pressing "OK" followed by "Cancel" (after a device error) the device text is garbled the next time the dialog is opened. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
parent
c4c636fb4f
commit
921bc51c87
1 changed files with 5 additions and 1 deletions
|
@ -70,7 +70,9 @@ static void set_default_dive_computer_device(const char *name)
|
|||
return;
|
||||
if (is_default_dive_computer_device(name))
|
||||
return;
|
||||
default_dive_computer_device = name;
|
||||
if (default_dive_computer_device)
|
||||
free((void *)default_dive_computer_device);
|
||||
default_dive_computer_device = strdup(name);
|
||||
subsurface_set_conf("dive_computer_device", PREF_STRING, name);
|
||||
}
|
||||
|
||||
|
@ -1105,6 +1107,8 @@ void exit_ui(void)
|
|||
free((char *)default_filename);
|
||||
if (existing_filename)
|
||||
free((void *)existing_filename);
|
||||
if (default_dive_computer_device)
|
||||
free((void *)default_dive_computer_device);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
|
|
Loading…
Reference in a new issue