diff --git a/Engine/source/platform/profiler.cpp b/Engine/source/platform/profiler.cpp index fb60453fc..c978b9ac2 100644 --- a/Engine/source/platform/profiler.cpp +++ b/Engine/source/platform/profiler.cpp @@ -214,12 +214,22 @@ Profiler::~Profiler() void Profiler::reset() { mEnabled = false; // in case we're in a profiler call. - while (mProfileList) + ProfilerData * head = mProfileList; + ProfilerData * curr = head; + + while ( curr ) { - free(mProfileList); - mProfileList = NULL; + head = curr->mNextProfilerData; + free( curr ); + + if ( head ) + curr = head; + else + curr = NULL; } + mProfileList = NULL; + for(ProfilerRootData *walk = ProfilerRootData::sRootList; walk; walk = walk->mNextRoot) { walk->mFirstProfilerData = 0;