mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
libdc: free value strings given by libdc's dc_parser_get_field()
Apparently libdc gives us copies of strings. The API is very scary, because (at least according to my reading of the code), the key/value pair may be stored in a cache. Thus on free()ing the string in the cache becomes invalid and we must not access it twice. Very obscure. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
6b1be8c4f6
commit
ac3042b48b
1 changed files with 2 additions and 1 deletions
|
@ -564,7 +564,7 @@ static void set_dc_serial(struct divecomputer *dc, const char *serial)
|
|||
{
|
||||
const struct device *device;
|
||||
|
||||
dc->serial = serial;
|
||||
dc->serial = strdup(serial);
|
||||
if ((device = get_device_for_dc(&device_table, dc)) != NULL)
|
||||
dc->deviceid = device_get_id(device);
|
||||
|
||||
|
@ -723,6 +723,7 @@ static dc_status_t libdc_header_parser(dc_parser_t *parser, device_data_t *devda
|
|||
if (!str.desc || !str.value)
|
||||
break;
|
||||
parse_string_field(devdata, dive, &str);
|
||||
free((void *)str.value); // libdc gives us copies of the value-string.
|
||||
}
|
||||
|
||||
dc_divemode_t divemode;
|
||||
|
|
Loading…
Add table
Reference in a new issue