Page MenuHome

(Possible) Memory leaks and other errors found by cppcheck
Closed, ArchivedPublic

Description

Resolution: Fixed

Well, I don't have the time to review them all.
The command line option "-a" is also set, so the output is likely filled with false positives. The errors generated by '-a' are marked by "(all)" and the errors that are more likely real errors are marked by "(error)".

[./extern/bullet2/src/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.h:43]: (all) Memory leak: btMultiSapBroadphase::m_optimizedAabbTree
[./extern/bullet2/src/BulletCollision/Gimpact/btGImpactShape.h:78]: (error) Class btGImpactShapeInterface which is inherited by class btGImpactMeshShape does not have a virtual destructor
[./extern/ode/dist/contrib/tri-collider/array.h:47]: (error) Class dArrayBase which is inherited by class dArray does not have a virtual destructor
[./extern/ode/dist/contrib/tri-collider/array.h:47]: (error) Class dArrayBase which is inherited by class dArray<int> does not have a virtual destructor
[./extern/ode/dist/contrib/tri-collider/array.h:47]: (error) Class dArrayBase which is inherited by class dArray<CollisionTriangle> does not have a virtual destructor
[./extern/ode/dist/drawstuff/src/windows.cpp:112]: (all) Array index out of bounds
[./extern/ode/dist/ode/src/array.h:47]: (error) Class dArrayBase which is inherited by class dArray does not have a virtual destructor
[./extern/ode/dist/ode/src/array.h:47]: (error) Class dArrayBase which is inherited by class dArray<int> does not have a virtual destructor
[./extern/solid/src/complex/DT_Complex.cpp:107]: (all) Memory leak: indices
[./extern/xvidcore/src/encoder.c:1954]: (error) Resource leak: fp
[./extern/xvidcore/src/plugins/plugin_2pass1.c:73]: (error) Memory leak: rc
[./extern/xvidcore/src/utils/mem_align.c:62]: (error) Memory leak: mem_ptr
[./intern/boolop/intern/BOP_Triangulator.cpp:95]: (all) Memory leak: face1
[./intern/boolop/intern/BOP_Triangulator.cpp:95]: (all) Memory leak: face2
[./intern/boolop/intern/BOP_Triangulator.cpp:130]: (all) Memory leak: face1
[./intern/boolop/intern/BOP_Triangulator.cpp:130]: (all) Memory leak: face2
[./intern/boolop/intern/BOP_Triangulator.cpp:130]: (all) Memory leak: face3
[./intern/boolop/intern/BOP_Triangulator.cpp:214]: (all) Memory leak: face1
[./intern/boolop/intern/BOP_Triangulator.cpp:214]: (all) Memory leak: face2
[./intern/boolop/intern/BOP_Triangulator.cpp:214]: (all) Memory leak: face3
[./intern/boolop/intern/BOP_Triangulator.cpp:281]: (all) Memory leak: face1
[./intern/boolop/intern/BOP_Triangulator.cpp:281]: (all) Memory leak: face2
[./intern/boolop/intern/BOP_Triangulator.cpp:281]: (all) Memory leak: face3
[./intern/boolop/intern/BOP_Triangulator.cpp:351]: (all) Memory leak: face1
[./intern/bsp/intern/CSG_BooleanOps.cpp:60]: (error) Memory leak: mesh_info
[./intern/bsp/intern/CSG_BooleanOps.cpp:60]: (all) Memory leak: output
[./intern/elbeem/intern/controlparticles.cpp:799]: (all) Memory leak: model
[./intern/elbeem/intern/ntl_bsptree.h:86]: (all) Memory leak: ntlTree::mpRoot
[./intern/elbeem/intern/ntl_geometryobject.h:181]: (all) Memory leak: ntlGeometryObject::mpMaterial
[./intern/elbeem/intern/particletracer.h:262]: (all) Memory leak: ParticleTracer::mpTrafo
[./intern/elbeem/intern/solver_class.h:512]: (all) Memory leak: LbmFsgrSolver::mpTest
[./intern/ghost/intern/GHOST_DisplayManagerCarbon.h:111]: (all) Memory leak: GHOST_DisplayManagerCarbon::m_displayIDs
[./intern/ghost/intern/GHOST_SystemX11.h:249]: (all) Memory leak: GHOST_SystemX11::m_keyboard_vector
[./intern/opennl/superlu/memory.c:41]: (error) Memory leak: buf
[./source/blender/blenkernel/intern/armature.c:2192]: (all) Array index out of bounds
[./source/blender/blenkernel/intern/exotic.c:3027]: (error) Resource leak: fp
[./source/blender/blenkernel/intern/exotic.c:3342]: (error) Resource leak: fp
[./source/blender/blenkernel/intern/object.c:2209]: (all) Buffer overrun
[./source/blender/blenkernel/intern/object.c:2234]: (all) Buffer overrun
[./source/blender/blenlib/intern/scanfill.c:428]: (error) Possible null pointer dereference
[./source/blender/ftfont/intern/FTF_TTFont.h:123]: (all) Memory leak: FTF_TTFont::font
[./source/blender/src/buttons_shading.c:397]: (error) Possible null pointer dereference
[./source/blender/src/drawview.c:1298]: (error) Overlapping data buffer shapes
[./source/blender/src/editmesh_loop.c:249]: (error) Overlapping data buffer msg
[./source/blender/src/editmesh_loop.c:251]: (error) Overlapping data buffer msg
[./source/blender/src/editmesh_tools.c:5994]: (error) Overlapping data buffer menu
[./source/blender/src/view.c:471]: (all) Buffer overrun
[./source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp:756]: (all) Memory leak: rendertools
[./source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp:756]: (all) Memory leak: rasterizer
[./source/gameengine/Converter/BL_BlenderDataConversion.cpp:2717]: (all) Memory leak: sumolist
[./source/gameengine/Converter/BL_BlenderDataConversion.cpp:2717]: (all) Memory leak: logicbrick_conversionlist
[./source/gameengine/Converter/KX_ConvertActuators.cpp:1173]: (all) Memory leak: uniqueval
[./source/gameengine/Converter/KX_ConvertControllers.cpp:232]: (all) Memory leak: uniqueval
[./source/gameengine/Converter/KX_ConvertSensors.cpp:816]: (all) Memory leak: uniqueval
[./source/gameengine/Converter/KX_IpoConvert.cpp:563]: (all) Memory leak: ipocontr
[./source/gameengine/Expressions/InputParser.h:81]: (all) Memory leak: CParser::errmsg
[./source/gameengine/Expressions/ListValue.cpp:183]: (all) Memory leak: listval_new
[./source/gameengine/Expressions/Operator1Expr.cpp:68]: (all) Memory leak: empty
[./source/gameengine/GameLogic/SCA_ILogicBrick.cpp:90]: (all) Memory leak: temp
[./source/gameengine/GameLogic/SCA_ILogicBrick.cpp:104]: (all) Memory leak: temp
[./source/gameengine/GameLogic/SCA_PropertyActuator.cpp:131]: (all) Memory leak: expr
[./source/gameengine/GameLogic/SCA_ISensor.h:105]: (error) Class SCA_ISensor which is inherited by class SCA_PropertySensor does not have a virtual destructor
[./source/gameengine/GameLogic/SCA_RandomActuator.cpp:260]: (all) Memory leak: tmpval
[./source/gameengine/GameLogic/SCA_RandomActuator.h:53]: (all) Memory leak: SCA_RandomActuator::m_base
[./source/gameengine/GameLogic/SCA_RandomSensor.h:46]: (all) Memory leak: SCA_RandomSensor::m_basegenerator
[./source/gameengine/GamePlayer/common/GPC_Engine.h:85]: (all) Memory leak: GPC_Engine::m_customLoadingAnimationURL
[./source/gameengine/GamePlayer/common/GPC_RawImage.h:112]: (all) Memory leak: GPC_RawImage::m_data
[./source/gameengine/GamePlayer/netscape/src/ketsji/KXH_ketsji_hooks.cpp:597]: (all) Memory leak: startSceneName
[./source/gameengine/GamePlayer/xembed/blenderplayer-wrapper.c:140]: (style) Found 'mktemp'. You should use 'mkstemp' instead
[./source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h:53]: (all) Memory leak: KX_NetworkMessageSensor::m_BodyList
[./source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h:54]: (all) Memory leak: KX_NetworkMessageSensor::m_SubjectList
[./source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp:295]: (error) Memory leak: smmaterial
[./source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp:295]: (all) Memory leak: sumoObj
[./source/gameengine/Ketsji/KX_GameObject.cpp:2687]: (all) Memory leak: polyproxy
[./source/gameengine/Ketsji/KX_GameObject.h:103]: (all) Memory leak: KX_GameObject::m_pSGNode
[./source/gameengine/Ketsji/KX_Scene.h:103]: (all) Memory leak: KX_Scene::m_tempObjectList
[./source/gameengine/Ketsji/KX_Scene.h:110]: (all) Memory leak: KX_Scene::m_euthanasyobjects
[./source/gameengine/Ketsji/KX_Scene.h:112]: (all) Memory leak: KX_Scene::m_objectlist
[./source/gameengine/Ketsji/KX_Scene.h:113]: (all) Memory leak: KX_Scene::m_parentlist
[./source/gameengine/Ketsji/KX_Scene.h:114]: (all) Memory leak: KX_Scene::m_lightlist
[./source/gameengine/Ketsji/KX_Scene.h:115]: (all) Memory leak: KX_Scene::m_inactivelist
[./source/gameengine/Ketsji/KX_Scene.h:135]: (all) Memory leak: KX_Scene::m_keyboardmgr
[./source/gameengine/Ketsji/KX_Scene.h:136]: (all) Memory leak: KX_Scene::m_mousemgr
[./source/gameengine/Ketsji/KX_Scene.h:137]: (all) Memory leak: KX_Scene::m_timemgr
[./source/gameengine/Ketsji/KX_Scene.h:185]: (all) Memory leak: KX_Scene::m_rootnode
[./source/gameengine/Ketsji/KX_TouchSensor.h:75]: (all) Memory leak: KX_TouchSensor::m_colliders
[./source/gameengine/Physics/Bullet/CcdPhysicsController.h:184]: (all) Memory leak: CcdShapeConstructionInfo::m_unscaledShape
[./source/gameengine/Physics/Bullet/CcdPhysicsController.h:337]: (all) Memory leak: CcdPhysicsController::m_collisionShape

Details

Type
Bug

Event Timeline

Thanks for running blender through cppcheck, I didnt know of this tool, though I had used splint before on blenders C code.

I had a look through all the C errors this reported and found these are either bad practice (like sprintf(buf, "%s blah blah", buf)), or cases where pointers could be NULL, but logically would never become NULL.
Some other errors are also reported in sample code we don't actually use.

Benoit looked through the game engine warnings and he recently committed fixes for some memory leaks (possibly some found here).

Since there is nothing more to do for this report Im closing it, thanks for pointing out some of the problems in blender, Ill make sure to run cppcheck every now and then :)

This task was automatically closed as archived as part of migration, because the project or tracker this task belonged to is no longer active.