1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-09-16 09:26:28 +02:00

fix ASAN detected leaks and heap-use-after-free error

This commit is contained in:
Mircea TheHonestCTO
2025-09-01 04:07:33 +02:00
parent 83e2bfde11
commit c55187d664
5 changed files with 13 additions and 5 deletions

View File

@@ -33,7 +33,7 @@ void AboutProjectView::hideAndStretchWidget(QGridLayout * layout, QWidget * toHi
AboutProjectView::AboutProjectView(QWidget * parent)
: QWidget(parent)
, ui(new Ui::AboutProjectView)
, ui(std::make_unique<Ui::AboutProjectView>())
{
ui->setupUi(this);
@@ -56,6 +56,8 @@ AboutProjectView::AboutProjectView(QWidget * parent)
#endif
}
AboutProjectView::~AboutProjectView() = default;
void AboutProjectView::changeEvent(QEvent *event)
{
if(event->type() == QEvent::LanguageChange)

View File

@@ -28,6 +28,7 @@ class AboutProjectView : public QWidget
public:
explicit AboutProjectView(QWidget * parent = nullptr);
~AboutProjectView() override;
private slots:
void on_updatesButton_clicked();
@@ -49,5 +50,5 @@ private slots:
void on_openConfigDir_clicked();
private:
Ui::AboutProjectView * ui;
std::unique_ptr<Ui::AboutProjectView> ui;
};

View File

@@ -41,7 +41,7 @@ extern "C" JNIEXPORT void JNICALL Java_eu_vcmi_vcmi_NativeMethods_heroesDataUpda
FirstLaunchView::FirstLaunchView(QWidget * parent)
: QWidget(parent)
, ui(new Ui::FirstLaunchView)
, ui(std::make_unique<Ui::FirstLaunchView>())
{
ui->setupUi(this);
@@ -65,6 +65,8 @@ FirstLaunchView::FirstLaunchView(QWidget * parent)
#endif
}
FirstLaunchView::~FirstLaunchView() = default;
void FirstLaunchView::on_buttonTabLanguage_clicked()
{
activateTabLanguage();

View File

@@ -58,6 +58,7 @@ class FirstLaunchView : public QWidget
public:
explicit FirstLaunchView(QWidget * parent = nullptr);
~FirstLaunchView() override;
// Tab Heroes III Data
bool heroesDataUpdate();
@@ -89,5 +90,5 @@ private slots:
void on_pushButtonGithub_clicked();
private:
Ui::FirstLaunchView * ui;
std::unique_ptr<Ui::FirstLaunchView> ui;
};

View File

@@ -73,17 +73,19 @@ void CDownloadManager::downloadFinished(QNetworkReply * reply)
if(possibleRedirectUrl.isValid())
{
QString filename;
qint64 totalSize = 0;
for(int i = 0; i< currentDownloads.size(); ++i)
{
if(currentDownloads[i].file == file.file)
{
filename = currentDownloads[i].filename;
totalSize = currentDownloads[i].totalSize;
currentDownloads.removeAt(i);
break;
}
}
downloadFile(qurl, filename, file.totalSize);
downloadFile(qurl, filename, totalSize);
return;
}