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:
Linus Torvalds 2021-08-17 04:12:03 -10:00 committed by Dirk Hohndel
parent 2c12648156
commit 47b0a9ce65

View file

@ -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;
}
}