If we tried to copy a divecomputer without samples, we where to malloc a
zero sized blob. dives/test15.xml triggered this and it was found with
valgrind.

Signed-off-by: Anton Lundin <[email protected]>
---
 dive.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dive.c b/dive.c
index bb92818..f5f4b28 100644
--- a/dive.c
+++ b/dive.c
@@ -597,7 +597,7 @@ void copy_samples(struct divecomputer *s, struct 
divecomputer *d)
 {
        /* instead of carefully copying them one by one and calling add_sample
         * over and over again, let's just copy the whole blob */
-       if (!s || !d)
+       if (!s || !d || !s->samples)
                return;
        int nr = s->samples;
        d->samples = nr;
-- 
2.1.0

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to