diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-06 20:17:30 +1100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-02-07 06:55:19 +1100 |
commit | 50170e0cf3ed22b7a1eca5426c9c5f9bd1bbf90d (patch) | |
tree | f7da3b80bb358905cb4b0a80f85aa6d5885b6f27 /libdivecomputer.c | |
parent | a1ef8e55028cb9344564d3d25b6e7b614cab71d8 (diff) | |
download | subsurface-50170e0cf3ed22b7a1eca5426c9c5f9bd1bbf90d.tar.gz |
Don't re-use the dive computer model string for all downloaded dives
When we download dives with libdivecomputer, we create this strdup'ed
name of the model information, but we then re-use that (single) strdup
allocation for every dive we download. This works fine *until* you
start freeing those dives (possibly directly after the download because
they are redundant), at which point things go to hell in a handbasket,
since there is just the one allocation for all the different dives.
Fix by just doing another strdup() at the point where we assign the
model information to the dive computer.
Reported-by: Marc Merlin <marc@merlins.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'libdivecomputer.c')
-rw-r--r-- | libdivecomputer.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libdivecomputer.c b/libdivecomputer.c index d41c27b29..f4f82fb8b 100644 --- a/libdivecomputer.c +++ b/libdivecomputer.c @@ -420,7 +420,7 @@ static int dive_cb(const unsigned char *data, unsigned int size, dc_parser_destroy(parser); return rc; } - dive->dc.model = devdata->model; + dive->dc.model = strdup(devdata->model); dive->dc.deviceid = devdata->deviceid; dive->dc.diveid = calculate_diveid(fingerprint, fsize); |