From 79e8799a0782a018833ec0003bb0e5086508da07 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 28 Feb 2014 20:55:17 +0300 Subject: fix some leaks issues. --- src/being/being.cpp | 1 + src/gui/widgets/textpreview.cpp | 24 ++++++++++++------------ src/net/download.cpp | 1 + src/resources/mapreader.cpp | 1 + 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/being/being.cpp b/src/being/being.cpp index 705d97439..41c3bc40c 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -3148,6 +3148,7 @@ void Being::removePet(const int id) actorManager->erase(pet); mPets.erase(it); delete pet; + return; } } } diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp index 8ac49bfd6..10bd936c6 100644 --- a/src/gui/widgets/textpreview.cpp +++ b/src/gui/widgets/textpreview.cpp @@ -80,6 +80,9 @@ TextPreview::~TextPreview() void TextPreview::draw(Graphics* graphics) { + if (!mFont) + return; + BLOCK_START("TextPreview::draw") if (client->getGuiAlpha() != mAlpha) mAlpha = client->getGuiAlpha(); @@ -99,18 +102,15 @@ void TextPreview::draw(Graphics* graphics) if (mTextBGColor) { - if (mFont) - { - const int x = mFont->getWidth(mText) + 1 - + 2 * ((mOutline || mShadow) ? 1 :0); - const int y = mFont->getHeight() + 1 - + 2 * ((mOutline || mShadow) ? 1 : 0); - graphics->setColor(Color(static_cast(mTextBGColor->r), - static_cast(mTextBGColor->g), - static_cast(mTextBGColor->b), - intAlpha)); - graphics->fillRectangle(Rect(mPadding, mPadding, x, y)); - } + const int x = mFont->getWidth(mText) + 1 + + 2 * ((mOutline || mShadow) ? 1 :0); + const int y = mFont->getHeight() + 1 + + 2 * ((mOutline || mShadow) ? 1 : 0); + graphics->setColor(Color(static_cast(mTextBGColor->r), + static_cast(mTextBGColor->g), + static_cast(mTextBGColor->b), + intAlpha)); + graphics->fillRectangle(Rect(mPadding, mPadding, x, y)); } graphics->setColorAll(Color(mTextColor->r, diff --git a/src/net/download.cpp b/src/net/download.cpp index d0c6515fc..141a7772f 100644 --- a/src/net/download.cpp +++ b/src/net/download.cpp @@ -568,6 +568,7 @@ size_t Download::writeFunction(void *ptr, memcpy(buf, ptr, totalMem); buf[totalMem] = 0; mUploadResponse.append(buf); + delete [] buf; return totalMem; } diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index e053e0035..4da901b09 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -214,6 +214,7 @@ void MapReader::addLayerToList(const std::string &fileName) mKnownLayers[name] = childNode; mKnownDocs.insert(doc); } + delete doc; } Map *MapReader::readMap(const std::string &restrict filename, -- cgit v1.2.3-70-g09d2