mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
DownloadFromDCWidget: prevent possible leaks for log/dump files
If the 'logfile_name' and 'dumpfile_name' were NULL we can simply strdup() them with a new value, but if there was a previous value we need to free() first. C99 6.7.8 allows us to keep said variables without the explicit NULL initialiazation. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
4d8168cc57
commit
a32462c26b
1 changed files with 8 additions and 2 deletions
|
@ -288,8 +288,11 @@ void DownloadFromDCWidget::pickLogFile()
|
|||
filename = fi.absolutePath().append(QDir::separator()).append("subsurface.log");
|
||||
logFile = QFileDialog::getSaveFileName(this, tr("Choose file for divecomputer download logfile"),
|
||||
filename, tr("Log files (*.log)"));
|
||||
if (!logFile.isEmpty())
|
||||
if (!logFile.isEmpty()) {
|
||||
if (logfile_name)
|
||||
free(logfile_name);
|
||||
logfile_name = strdup(logFile.toUtf8().data());
|
||||
}
|
||||
}
|
||||
|
||||
void DownloadFromDCWidget::checkDumpFile(int state)
|
||||
|
@ -314,8 +317,11 @@ void DownloadFromDCWidget::pickDumpFile()
|
|||
filename = fi.absolutePath().append(QDir::separator()).append("subsurface.bin");
|
||||
dumpFile = QFileDialog::getSaveFileName(this, tr("Choose file for divecomputer binary dump file"),
|
||||
filename, tr("Dump files (*.bin)"));
|
||||
if (!dumpFile.isEmpty())
|
||||
if (!dumpFile.isEmpty()) {
|
||||
if (dumpfile_name)
|
||||
free(dumpfile_name);
|
||||
dumpfile_name = strdup(dumpFile.toUtf8().data());
|
||||
}
|
||||
}
|
||||
|
||||
void DownloadFromDCWidget::reject()
|
||||
|
|
Loading…
Reference in a new issue