From fffbd86a1014ad169ed2d68ea58cdddf346faa14 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 21 Jul 2015 00:47:44 +0300 Subject: Add missing checks and non null attributes. --- src/gui/windows/charcreatedialog.cpp | 24 ++++++++++++++++-------- src/gui/windows/maileditwindow.cpp | 11 +++++++---- src/gui/windows/updaterwindow.cpp | 11 ++++++++++- 3 files changed, 33 insertions(+), 13 deletions(-) (limited to 'src/gui/windows') diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp index eba1dd96e..2168ad0a1 100644 --- a/src/gui/windows/charcreatedialog.cpp +++ b/src/gui/windows/charcreatedialog.cpp @@ -268,20 +268,28 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent, if (serverFeatures->haveLookSelection() && mMinLook < mMaxLook) { y += 24; - mPrevLookButton->setPosition(leftX, y); - mNextLookButton->setPosition(rightX, y); + if (mPrevLookButton) + mPrevLookButton->setPosition(leftX, y); + if (mNextLookButton) + mNextLookButton->setPosition(rightX, y); y += 5; - mLookLabel->setPosition(labelX, y); - mLookNameLabel->setPosition(nameX, y); // 93 + if (mLookLabel) + mLookLabel->setPosition(labelX, y); + if (mLookNameLabel) + mLookNameLabel->setPosition(nameX, y); // 93 } if (serverFeatures->haveRaceSelection()) { y += 24; - mPrevRaceButton->setPosition(leftX, y); - mNextRaceButton->setPosition(rightX, y); + if (mPrevRaceButton) + mPrevRaceButton->setPosition(leftX, y); + if (mNextRaceButton) + mNextRaceButton->setPosition(rightX, y); y += 5; - mRaceLabel->setPosition(labelX, y); - mRaceNameLabel->setPosition(nameX, y); + if (mRaceLabel) + mRaceLabel->setPosition(labelX, y); + if (mRaceNameLabel) + mRaceNameLabel->setPosition(nameX, y); } updateSliders(); diff --git a/src/gui/windows/maileditwindow.cpp b/src/gui/windows/maileditwindow.cpp index 12ab097c0..1699b979c 100644 --- a/src/gui/windows/maileditwindow.cpp +++ b/src/gui/windows/maileditwindow.cpp @@ -136,11 +136,14 @@ void MailEditWindow::action(const ActionEvent &event) if (tempItem) { const Inventory *const inv = PlayerInfo::getInventory(); - const Item *const item = inv->findItem(tempItem->getId(), 1); - if (item) + if (inv) { - mailHandler->setAttach(item->getInvIndex(), - tempItem->getQuantity()); + const Item *const item = inv->findItem(tempItem->getId(), 1); + if (item) + { + mailHandler->setAttach(item->getInvIndex(), + tempItem->getQuantity()); + } } } diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp index e221b73b9..9330539ab 100644 --- a/src/gui/windows/updaterwindow.cpp +++ b/src/gui/windows/updaterwindow.cpp @@ -362,7 +362,11 @@ void UpdaterWindow::loadNews() // Reallocate and include terminating 0 character mMemoryBuffer = static_cast(realloc( mMemoryBuffer, mDownloadedBytes + 1)); - + if (!mMemoryBuffer) + { + logger->log1("Couldn't load news"); + return; + } mMemoryBuffer[mDownloadedBytes] = '\0'; mBrowserBox->clearRows(); @@ -425,6 +429,11 @@ void UpdaterWindow::loadPatch() // Reallocate and include terminating 0 character mMemoryBuffer = static_cast( realloc(mMemoryBuffer, mDownloadedBytes + 1)); + if (!mMemoryBuffer) + { + logger->log1("Couldn't load patch"); + return; + } mMemoryBuffer[mDownloadedBytes] = '\0'; std::string version; -- cgit v1.2.3-70-g09d2