Initialize alloc_samples in copy_samples

We rely on alloc_samples in prepare_sample. If alloc_samples weren't
initialized prepare_sample would wreak havoc on the samples list.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Anton Lundin 2014-12-12 08:59:11 +01:00 committed by Dirk Hohndel
parent e7698beea7
commit 46bd71a184

1
dive.c
View file

@ -601,6 +601,7 @@ void copy_samples(struct divecomputer *s, struct divecomputer *d)
return;
int nr = s->samples;
d->samples = nr;
d->alloc_samples = nr;
d->sample = malloc(nr * sizeof(struct sample));
if (d->sample)
memcpy(d->sample, s->sample, nr * sizeof(struct sample));