diff options
author | Lubomir I. Ivanov <neolit123@gmail.com> | 2012-09-22 19:07:50 +0300 |
---|---|---|
committer | Lubomir I. Ivanov <neolit123@gmail.com> | 2012-09-23 17:14:53 +0300 |
commit | 921bc51c879648afc81bfb1b1f1a154e8b97ce6e (patch) | |
tree | c72fb4e858a715f918b34491d9918a39d85f5c03 /gtk-gui.c | |
parent | c4c636fb4ffa942f282d57556a579de311b96c43 (diff) | |
download | subsurface-921bc51c879648afc81bfb1b1f1a154e8b97ce6e.tar.gz |
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>
Diffstat (limited to 'gtk-gui.c')
-rw-r--r-- | gtk-gui.c | 6 |
1 files changed, 5 insertions, 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 { |