mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Don't share dive computer data allocations
... it just causes problems later when we free them, since we don't do any reference counting. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
2c12648156
commit
47b0a9ce65
1 changed files with 3 additions and 4 deletions
|
@ -474,14 +474,13 @@ void remove_event_from_dc(struct divecomputer *dc, struct event *event)
|
|||
void add_extra_data(struct divecomputer *dc, const char *key, const char *value)
|
||||
{
|
||||
struct extra_data **ed = &dc->extra_data;
|
||||
const char *newval = strdup(value);
|
||||
|
||||
if (!strcasecmp(key, "Serial")) {
|
||||
dc->deviceid = calculate_string_hash(value);
|
||||
dc->serial = newval;
|
||||
dc->serial = strdup(value);
|
||||
}
|
||||
if (!strcmp(key, "FW Version")) {
|
||||
dc->fw_version = newval;
|
||||
dc->fw_version = strdup(value);
|
||||
}
|
||||
|
||||
while (*ed)
|
||||
|
@ -489,7 +488,7 @@ void add_extra_data(struct divecomputer *dc, const char *key, const char *value)
|
|||
*ed = malloc(sizeof(struct extra_data));
|
||||
if (*ed) {
|
||||
(*ed)->key = strdup(key);
|
||||
(*ed)->value = newval;
|
||||
(*ed)->value = strdup(value);
|
||||
(*ed)->next = NULL;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue