<html>
<head>
<base href="https://bugs.documentfoundation.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_UNCONFIRMED "
title="UNCONFIRMED - Possible write to free'd memory in OResultSet.cxx"
href="https://bugs.documentfoundation.org/show_bug.cgi?id=112947">112947</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Possible write to free'd memory in OResultSet.cxx
</td>
</tr>
<tr>
<th>Product</th>
<td>LibreOffice
</td>
</tr>
<tr>
<th>Version</th>
<td>5.4.2.2 release
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>UNCONFIRMED
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>medium
</td>
</tr>
<tr>
<th>Component</th>
<td>LibreOffice
</td>
</tr>
<tr>
<th>Assignee</th>
<td>libreoffice-bugs@lists.freedesktop.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>nick@lurcher.org
</td>
</tr></table>
<p>
<div>
<pre>I noticed while writing an ODBC driver and running with valgrind I noticed that
creating a DB query could lead to the driver writing to free'd space.
Process is in OResultSet.cxx
Row status array is allocated and set in the driver
m_pRowStatusArray = new SQLUSMALLINT[1]; // the default value
setStmtOption<SQLUSMALLINT*, SQL_IS_POINTER>(SQL_ATTR_ROW_STATUS_PTR,
m_pRowStatusArray);
However in the destructor, when OResultSet is released, m_pRowStatusArray is
released, but the address is not reset in the ODBC driver, so next time that
statement is used, that address is referenced.
A simple (and seems to work) fix is to reset the value when its released.
OResultSet::~OResultSet()
{
setStmtOption<SQLUSMALLINT*, SQL_IS_POINTER>(SQL_ATTR_ROW_STATUS_PTR,
NULL);
delete [] m_pRowStatusArray;
delete m_pSkipDeletedSet;
}</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>