cleanup: fix leak in CylindersModel::setData()

The C-string cyl->type.description was set without the old data
being freed. Free the old string before overwriting the pointer.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2020-02-28 13:53:34 +01:00 committed by Dirk Hohndel
parent f55c15e5f9
commit ee1c438d41

View file

@ -322,6 +322,7 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
QByteArray ba = value.toByteArray();
const char *text = ba.constData();
if (!cyl->type.description || strcmp(cyl->type.description, text)) {
free((void *)cyl->type.description);
cyl->type.description = strdup(text);
changed = true;
}