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 60fb75b03a
commit 5c5f87445b

@ -516,6 +516,16 @@ namespace MWMechanics
Actors::Actors() {}
Actors::~Actors()
{
PtrControllerMap::iterator it(mActors.begin());
for (; it != mActors.end(); ++it)
{
delete it->second;
it->second = NULL;
}
}
void Actors::addActor (const MWWorld::Ptr& ptr)
{
// erase previous death events since we are currently only tracking them while in an active cell

@ -49,6 +49,7 @@ namespace MWMechanics
public:
Actors();
~Actors();
/// Update magic effects for an actor. Usually done automatically once per frame, but if we're currently
/// paused we may want to do it manually (after equipping permanent enchantment)

@ -14,6 +14,16 @@ Objects::Objects()
{
}
Objects::~Objects()
{
PtrControllerMap::iterator it(mObjects.begin());
for (; it != mObjects.end();++it)
{
delete it->second;
it->second = NULL;
}
}
void Objects::addObject(const MWWorld::Ptr& ptr)
{
removeObject(ptr);

@ -21,6 +21,7 @@ namespace MWMechanics
public:
Objects();
~Objects();
void addObject (const MWWorld::Ptr& ptr);
///< Register an animated object

@ -19,25 +19,27 @@ namespace MWRender
Camera::Camera (Ogre::Camera *camera)
: mCamera(camera),
mCameraNode(NULL),
mAnimation(NULL),
mFirstPersonView(true),
mPreviewMode(false),
mFreeLook(true),
mHeight(128.f),
mCameraDistance(300.f),
mDistanceAdjusted(false),
mAnimation(NULL),
mNearest(30.f),
mFurthest(800.f),
mIsNearest(false),
mIsFurthest(false),
mHeight(128.f),
mCameraDistance(300.f),
mDistanceAdjusted(false),
mVanityToggleQueued(false),
mViewModeToggleQueued(false)
{
mVanity.enabled = false;
mVanity.allowed = true;
mPreviewCam.pitch = 0.f;
mPreviewCam.yaw = 0.f;
mPreviewCam.offset = 400.f;
mMainCam.pitch = 0.f;
mMainCam.yaw = 0.f;
mMainCam.offset = 400.f;
}

@ -292,6 +292,7 @@ Water::~Water()
delete mReflection;
delete mRefraction;
delete mSimulation;
}
void Water::changeCell(const ESM::Cell* cell)

@ -158,6 +158,11 @@ void FFmpeg_Decoder::open(const std::string &fname)
mFormatCtx->pb = avio_alloc_context(NULL, 0, 0, this, readPacket, writePacket, seek);
if(!mFormatCtx->pb || avformat_open_input(&mFormatCtx, fname.c_str(), NULL, NULL) != 0)
{
if (mFormatCtx->pb != NULL)
{
avio_close(mFormatCtx->pb);
mFormatCtx->pb = NULL;
}
avformat_free_context(mFormatCtx);
mFormatCtx = NULL;
fail("Failed to allocate input stream");
@ -195,6 +200,9 @@ void FFmpeg_Decoder::open(const std::string &fname)
}
catch(std::exception &e)
{
avio_close(mFormatCtx->pb);
mFormatCtx->pb = NULL;
avformat_close_input(&mFormatCtx);
throw;
}
@ -211,9 +219,22 @@ void FFmpeg_Decoder::close()
if(mFormatCtx)
{
AVIOContext* context = mFormatCtx->pb;
if (mFormatCtx->pb != NULL)
{
avio_flush(mFormatCtx->pb);
//
// avio-close() gives segfault, but with av_free valgrind shows memleak
// near mFormatCtx->pb
//
// to be checked!
//
// avio_close(mFormatCtx->pb);
//
av_free(mFormatCtx->pb);
mFormatCtx->pb = NULL;
}
avformat_close_input(&mFormatCtx);
av_free(context);
}
mDataStream.setNull();

@ -74,8 +74,9 @@ namespace OEngine
, mScene(NULL)
, mCamera(NULL)
, mView(NULL)
, mWindowListener(NULL)
, mOgreInit(NULL)
, mFader(NULL)
, mWindowListener(NULL)
{
}

Loading…
Cancel
Save