mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Make sure we always have copies of equipment descriptions
Having pointers copied around that might get freed elsewhere could be a problem. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
1055b5afd3
commit
8d766e13e2
4 changed files with 13 additions and 5 deletions
8
dive.c
8
dive.c
|
@ -434,6 +434,10 @@ void clear_dive(struct dive *d)
|
|||
taglist_free(d->tag_list);
|
||||
STRUCTURED_LIST_FREE(struct divecomputer, d->dc.next, free_dc);
|
||||
STRUCTURED_LIST_FREE(struct picture, d->picture_list, free_pic);
|
||||
for (int i = 0; i < MAX_CYLINDERS; i++)
|
||||
free((void *)d->cylinder[i].type.description);
|
||||
for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++)
|
||||
free((void *)d->weightsystem[i].description);
|
||||
memset(d, 0, sizeof(struct dive));
|
||||
}
|
||||
|
||||
|
@ -452,6 +456,10 @@ void copy_dive(struct dive *s, struct dive *d)
|
|||
d->location = copy_string(s->location);
|
||||
d->notes = copy_string(s->notes);
|
||||
d->suit = copy_string(s->suit);
|
||||
for (int i = 0; i < MAX_CYLINDERS; i++)
|
||||
d->cylinder[i].type.description = copy_string(s->cylinder[i].type.description);
|
||||
for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++)
|
||||
d->weightsystem[i].description = copy_string(s->weightsystem[i].description);
|
||||
STRUCTURED_LIST_COPY(struct picture, s->picture_list, d->picture_list, copy_pl);
|
||||
STRUCTURED_LIST_COPY(struct tag_entry, s->tag_list, d->tag_list, copy_tl);
|
||||
STRUCTURED_LIST_COPY(struct divecomputer, s->dc.next, d->dc.next, copy_dc);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue