aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2021-08-17 04:12:03 -1000
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-08-18 13:22:02 -0700
commit47b0a9ce65e1b088c1b1e86e89af3bcb070b6bbb (patch)
tree4b497f5f85ce98e208c4e4e83ecf0c4042a4dfe8
parent2c12648156a85efa038e0dfd566cef43f9d46eca (diff)
downloadsubsurface-47b0a9ce65e1b088c1b1e86e89af3bcb070b6bbb.tar.gz
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>
-rw-r--r--core/divecomputer.c7
1 files 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;
}
}