<div dir="ltr">Linus,<br><div><div class="gmail_extra"><br><div class="gmail_quote">On 1 June 2016 at 03:10, Linus Torvalds <span dir="ltr"><<a href="mailto:torvalds@linux-foundation.org" target="_blank">torvalds@linux-foundation.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
From: Linus Torvalds <<a href="mailto:torvalds@linux-foundation.org">torvalds@linux-foundation.org</a>><br>
Date: Mon, 11 Apr 2016 14:25:03 -0700<br>
Subject: [PATCH 1/2] Make 'clear_dive()' free the primary dive computer data properly<br>
<br>
Our primary dive computer really is special, not just because it's the<br>
first one: it's directly embedded in the "struct dive", and so if you<br>
just walk the divecomputer list, you'll miss it, because it's not _on_<br>
the list, it is the very head _of_ the list.<br>
<br>
We had that bug in copy_dive(), and it turns out we have it in<br>
clear_dive() too: clear_dive() would free all the dive computers on the<br>
list, but not the actual primary one.<br>
<br>
This is a minor memory leak, no more, so it's not exactly critial, but<br>
let's just do it right.<br>
<br>
Signed-off-by: Linus Torvalds <<a href="mailto:torvalds@linux-foundation.org">torvalds@linux-foundation.org</a>><br>
---<br>
 core/dive.c | 9 ++++++++-<br>
 1 file changed, 8 insertions(+), 1 deletion(-)<br>
<br></blockquote><div> </div><div>This change leads to an invalid pointer error when cancelling a planned dive.<br><br>*** Error in `/home/rick/src/subsurface/build/subsurface': munmap_chunk(): invalid pointer: 0x0000000000803f5d ***<br>======= Backtrace: =========<br>/lib64/libc.so.6(+0x77d75)[0x7ffff0e50d75]<br>/lib64/libc.so.6(cfree+0x1a8)[0x7ffff0e5c888]<br>/home/rick/src/subsurface/build/subsurface[0x6946b6]<br>/home/rick/src/subsurface/build/subsurface(clear_dive+0x7f)[0x69044d]<br>/home/rick/src/subsurface/build/subsurface(copy_dive+0x1c)[0x69055e]<br>/home/rick/src/subsurface/build/subsurface(_ZN14ProfileWidget28plotDiveEP4diveb+0x116)[0x627fe8]<br>/home/rick/src/subsurface/build/subsurface(_ZN14ProfileWidget26replotEP4dive+0x47)[0x626de9]<br>/home/rick/src/subsurface/build/subsurface(_ZN10MainWindow14refreshProfileEv+0x4f)[0x512185]<br>/home/rick/src/subsurface/build/subsurface(_ZN10MainWindow12planCanceledEv+0x18)[0x5121bc]<br>/home/rick/src/subsurface/build/subsurface[0x5bafb3]<br>/lib64/libQt5Core.so.5(_ZN11QMetaObject8activateEP7QObjectiiPPv+0x690)[0x7ffff1c0bdf0]<br>/home/rick/src/subsurface/build/subsurface(_ZN22DivePlannerPointsModel12planCanceledEv+0x29)[0x685245]<br>/home/rick/src/subsurface/build/subsurface(_ZN22DivePlannerPointsModel10cancelPlanEv+0x39)[0x65d901]<br>/home/rick/src/subsurface/build/subsurface[0x684e43]<br><br></div><div>Do you know what the fix could be?<br><br></div><div>Rick<br></div><div> <br></div></div></div></div></div>