From 47b0a9ce65e1b088c1b1e86e89af3bcb070b6bbb Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Tue, 17 Aug 2021 04:12:03 -1000 Subject: 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 --- core/divecomputer.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/core/divecomputer.c b/core/divecomputer.c index 289f9efa2..19d4a6fee 100644 --- a/core/divecomputer.c +++ b/core/divecomputer.c @@ -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; } } -- cgit v1.2.3-70-g09d2