mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
cleanup: fix tiny memory hole in device.cpp
empty_string() returns true for "". Thus, we can't simply overwrite the pointer if empyt_string() returns true, but must free the string regardless. The joys of C memory management! Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
485ac4b58f
commit
4e479677a0
1 changed files with 6 additions and 2 deletions
|
@ -238,10 +238,14 @@ extern "C" void set_dc_deviceid(struct divecomputer *dc, unsigned int deviceid)
|
|||
if (!node)
|
||||
return;
|
||||
|
||||
if (!node->serialNumber.isEmpty() && empty_string(dc->serial))
|
||||
if (!node->serialNumber.isEmpty() && empty_string(dc->serial)) {
|
||||
free((void *)dc->serial);
|
||||
dc->serial = copy_qstring(node->serialNumber);
|
||||
if (!node->firmware.isEmpty() && empty_string(dc->fw_version))
|
||||
}
|
||||
if (!node->firmware.isEmpty() && empty_string(dc->fw_version)) {
|
||||
free((void *)dc->fw_version);
|
||||
dc->fw_version = copy_qstring(node->firmware);
|
||||
}
|
||||
}
|
||||
|
||||
void device::showchanges(const QString &n, const QString &s, const QString &f) const
|
||||
|
|
Loading…
Reference in a new issue