Open
Description
int Move_Rows_Down(_ListboxData *data, int row)
{
int size = sizeof(_ListEntryRow) * (data->m_endPos - row);
char *buf = new char[size];
memcpy(buf, &data->m_listData[row], size);
memcpy(&data->m_listData[row + 1], buf, size);
delete[] buf;
...
}
It allocates a buf, copies data->m_listData[row]
into buf
, and copies buf
into data->m_listData[row + 1]
.
This makes no sense. It can copy data->m_listData[row]
directly into data->m_listData[row + 1]
:
memcpy(&data->m_listData[row + 1], &data->m_listData[row], size);
Alternatively, perhaps this meant to swap the rows? In that case one would need to add as 2nd copy step:
memcpy(&data->m_listData[row], &data->m_listData[row + 1], size);