Fixes for "Conditional jump or move depends on uninitialised value(s)"

and memleaks reported by valgrind.

Signed-off-by: Lukasz Gromanowski <lgromanowski@gmail.com>
actorid
Lukasz Gromanowski 11 years ago
parent 6107d5bad2
commit cb04f43384

@ -55,6 +55,8 @@ namespace MWGui
, mWorldMouseOver(false)
, mEnemyHealthTimer(0)
, mIsDrowning(false)
, mWeaponSpellTimer(0.f)
, mDrowningFlashTheta(0.f)
{
setCoord(0,0, width, height);

@ -16,6 +16,15 @@ namespace MWGui
mLastButtonPressed = -1;
}
MessageBoxManager::~MessageBoxManager ()
{
std::vector<MessageBox*>::iterator it(mMessageBoxes.begin());
for (; it != mMessageBoxes.end(); ++it)
{
delete *it;
}
}
void MessageBoxManager::onFrame (float frameDuration)
{
std::vector<MessageBox*>::iterator it;

@ -23,6 +23,7 @@ namespace MWGui
{
public:
MessageBoxManager ();
~MessageBoxManager ();
void onFrame (float frameDuration);
void createMessageBox (const std::string& message, bool stat = false);
void removeStaticMessageBox ();

@ -322,6 +322,7 @@ namespace MWGui
delete mSoulgemDialog;
delete mCursorManager;
delete mRecharge;
delete mCompanionWindow;
cleanupGarbage();

@ -950,8 +950,22 @@ void VideoState::init(const std::string& resourceName)
// Open video file
/// \todo leak here, ffmpeg or valgrind bug ?
///
/// https://trac.ffmpeg.org/ticket/1357
///
if(!this->format_ctx || avformat_open_input(&this->format_ctx, resourceName.c_str(), NULL, NULL))
{
if (this->format_ctx != NULL)
{
if (this->format_ctx->pb != NULL)
{
av_free(this->format_ctx->pb->buffer);
this->format_ctx->pb->buffer = NULL;
av_free(this->format_ctx->pb);
this->format_ctx->pb = NULL;
}
}
// "Note that a user-supplied AVFormatContext will be freed on failure."
this->format_ctx = NULL;
av_free(ioCtx);
@ -1009,9 +1023,20 @@ void VideoState::deinit()
if(this->format_ctx)
{
AVIOContext *ioContext = this->format_ctx->pb;
// valgrind shows memleak near format_ctx->pb
//
// As scrawl pointed, memleak could be related to this ffmpeg ticket:
// https://trac.ffmpeg.org/ticket/1357
//
if (this->format_ctx->pb != NULL)
{
av_free(this->format_ctx->pb->buffer);
this->format_ctx->pb->buffer = NULL;
av_free(this->format_ctx->pb);
this->format_ctx->pb = NULL;;
}
avformat_close_input(&this->format_ctx);
av_free(ioContext);
}
}

Loading…
Cancel
Save