<div dir="ltr"><pre style="white-space:pre-wrap;font-size:13px;margin-top:1.5em;margin-bottom:1.5em;padding:0px;border:0px;outline:0px;vertical-align:baseline;overflow:auto;color:black"><pre style="white-space:pre-wrap;margin-top:1.5em;margin-bottom:1.5em;padding:0px;border:0px;outline:0px;vertical-align:baseline;overflow:auto">Package: aptitude</pre><pre style="white-space:pre-wrap;margin-top:1.5em;margin-bottom:1.5em;padding:0px;border:0px;outline:0px;vertical-align:baseline;overflow:auto">Version: 0.8.12</pre><pre style="white-space:pre-wrap;margin-top:1.5em;margin-bottom:1.5em;padding:0px;border:0px;outline:0px;vertical-align:baseline;overflow:auto">Source: aptitude</pre></pre><pre style="white-space:pre-wrap;font-size:13px;margin-top:1.5em;margin-bottom:1.5em;padding:0px;border:0px;outline:0px;vertical-align:baseline;overflow:auto;color:black">I downloaded the newest source code from:<a href="http://deb.debian.org/debian/pool/main/a/aptitude/aptitude_0.8.12.orig.tar.xz">http://deb.debian.org/debian/pool/main/a/aptitude/aptitude_0.8.12.orig.tar.xz</a>. The bug lies in src/generic/util/sqlite.cc:201-202:</pre><pre style="white-space:pre-wrap;font-size:13px;margin-top:1.5em;margin-bottom:1.5em;padding:0px;border:0px;outline:0px;vertical-align:baseline;overflow:auto;color:black">201:  int result = sqlite3_exec(handle, sql.c_str(),<br>202:                     callback, data, &msg);<br></pre><pre style="white-space:pre-wrap;font-size:13px;margin-top:1.5em;margin-bottom:1.5em;padding:0px;border:0px;outline:0px;vertical-align:baseline;overflow:auto;color:black">According to libsqlite3 API document of 'sqlite3_exec': "To avoid memory leaks, the application should invoke sqlite3_free() on error message strings returned through the 5th parameter of sqlite3_exec() after the error message string is no longer needed."</pre><pre style="white-space:pre-wrap;font-size:13px;margin-top:1.5em;margin-bottom:1.5em;padding:0px;border:0px;outline:0px;vertical-align:baseline;overflow:auto;color:black">So this is potential memory leak, and the patch should be:</pre><pre style="white-space:pre-wrap;font-size:13px;margin-top:1.5em;margin-bottom:1.5em;padding:0px;border:0px;outline:0px;vertical-align:baseline;overflow:auto;color:black">208:   if(result != SQLITE_OK || msg != NULL)<br>209:      throw exception(errmsg, result);<br>210:+ if(msg)<br>211:+          sqlite3_free(msg)<br></pre><pre style="white-space:pre-wrap;font-size:13px;margin-top:1.5em;margin-bottom:1.5em;padding:0px;border:0px;outline:0px;vertical-align:baseline;overflow:auto;color:black"></pre></div>