Arx Libertatis Bug Tracker
star_faded.png
Please log in to bookmark issues
bug_report_small.png
CLOSED  Bug report #461  -  cppcheck results, some memory leaks
Posted Feb 14, 2013 - updated Jul 06, 2013   Shortlink: http://arx.vg/461
action_vote_minus_faded.png
0
Votes
action_vote_plus_faded.png
icon_info.png This issue has been closed with status "Postponed" and resolution "POSTPONED".
Issue details
  • Type of issue
    Bug report
  • Status
     
    Postponed
  • Assigned to
    Not assigned to anyone
  • Progress
       
  • Type of bug
    Not triaged
  • Likelihood
    Not triaged
  • Effect
    Not triaged
  • Posted by
     Guest user
  • Owned by
    Not owned by anyone
  • Estimated time
    Not estimated
  • Category
    Not determined
  • Resolution
    POSTPONED
  • Priority
    Not determined
  • Reproducability
    Not determined
  • Severity
    Not determined
  • Targetted for
    icon_milestones.png Not determined
  • OS
    icon_customdatatype.png Not determined
  • Architecture
    icon_customdatatype.png Not determined
  • Fixed in
    icon_customdatatype.png Not determined
Issue description
Here are some easy hacks, reported by "cppcheck" (open source C++ static analyzer). Most of them are minor (style, performance, etc), but there are also some real errors like memory leaks, suspicous calculations and null pointer derefs.

  1. [ai\PathFinder.cpp:68]: (style) The class 'PathFinder' does not have a constructor.
  2. [ai\PathFinder.cpp:78]: (performance, inconclusive) Technically the member function 'PathFinder::Node' can be static.
  3. [ai\PathFinderManager.cpp:137]: (style) C-style pointer casting
  4. [ai\Paths.cpp:1070] -> [ai\Paths.cpp:1071]: (performance) Variable 'rad' is reassigned a value before the old one has been used.
  5. [ai\Paths.cpp:1091]: (style) The scope of the variable 'weapon_material' can be reduced.
  6. [ai\Paths.cpp:1115]: (style) The scope of the variable 'weapon_material' can be reduced.
  7. [ai\Paths.cpp:1116]: (style) The scope of the variable 'bkg_material' can be reduced.
  8. [animation\Animation.cpp:1000]: (style) The scope of the variable 'k' can be reduced.
  9. [animation\Animation.cpp:1002]: (style) The scope of the variable 'lfr' can be reduced.
  10. [animation\Animation.cpp:1002]: (style) The scope of the variable 'lfg' can be reduced.
  11. [animation\Animation.cpp:1002]: (style) The scope of the variable 'lfb' can be reduced.
  12. [animation\Animation.cpp:599]: (style) Checking if unsigned variable 'time' is less than zero.
  13. [animation\AnimationRender.cpp:1934]: (style) The scope of the variable 'obj' can be reduced.
  14. [animation\AnimationRender.cpp:1951]: (error) Common realloc mistake: 'grps' nulled but not freed upon failure
  15. [animation\AnimationRender.cpp:1236]: (style) The scope of the variable 'iNbTotVertex' can be reduced.
  16. [animation\AnimationRender.cpp:1291]: (style) Variable 'iNbTotVertex' is assigned a value that is never used.
  17. [audio\Ambiance.cpp:233]: (style) The struct 'Ambiance' does not have a constructor.
  18. [audio\codec\WAV.cpp:69]: (style, inconclusive) Technically the member function 'ChunkFile::size' can be const.
  19. [core\Application.cpp:307]: (style) Variable 'fFPS' is assigned a value that is never used.
  20. [core\ArxGame.cpp:2024]: (style) The scope of the variable 'pTableIO' can be reduced.
  21. [core\ArxGame.cpp:351]: (style) Variable 'autoFramework' is assigned a value that is never used.
  22. [core\Core.cpp:3104]: (style) The scope of the variable 'SPLASH_DURATION' can be reduced.
  23. [core\SaveGame.cpp:226]: (performance) Prefer prefix ++/-- operators for non-primitive types.
  24. [game\Equipment.cpp:390]: (style) Boolean result is used in bitwise operation. Clarify expression with parentheses.
  25. [game\Inventory.cpp:1253] -> [game\Inventory.cpp:1261]: (error) Possible null pointer dereference: DRAGINTER - otherwise it is redundant to check it against null.
  26. [game\Inventory.cpp:1254] -> [game\Inventory.cpp:1261]: (error) Possible null pointer dereference: DRAGINTER - otherwise it is redundant to check it against null.
  27. [game\Inventory.cpp:900]: (style) The scope of the variable 'i' can be reduced.
  28. [game\Inventory.cpp:900]: (style) The scope of the variable 'j' can be reduced.
  29. [game\Inventory.cpp:900]: (style) The scope of the variable 'k' can be reduced.
  30. [game\Inventory.cpp:900]: (style) The scope of the variable 'l' can be reduced.
  31. [game\Inventory.cpp:1928]: (style) The scope of the variable 'i' can be reduced.
  32. [game\Inventory.cpp:1928]: (style) The scope of the variable 'j' can be reduced.
  33. [game\NPC.cpp:2877] -> [game\NPC.cpp:2877]: (style) Same expression on both sides of '||'.
  34. [game\NPC.cpp:2981]: (style) The scope of the variable 'CHANGE' can be reduced.
  35. [game\Spells.cpp:6092] -> [game\Spells.cpp:6086]: (error, inconclusive) Possible null pointer dereference: pCSpellFX - otherwise it is redundant to check it against null.
  36. [game\Spells.cpp:658]: (style) C-style pointer casting
  37. [game\Spells.cpp:752]: (style) C-style pointer casting
  38. [game\Spells.cpp:1961]: (style) Consecutive return, break, continue, goto or throw statements are unnecessary.
  39. [game\Spells.cpp:2388]: (style) Boolean result is used in bitwise operation. Clarify expression with parentheses.
  40. [game\Spells.cpp:2005]: (style) Unused variable: tex
  41. [graphics\d3d9\D3D9Renderer.cpp:162]: (style) struct or union member 'D3DLVERTEX::dvX' is never used.
  42. [graphics\data\CinematicTexture.cpp:321]: (warning, inconclusive) Division with signed and unsigned operators. The result might be wrong.
  43. [graphics\data\CinematicTexture.cpp:322]: (warning, inconclusive) Division with signed and unsigned operators. The result might be wrong.
  44. [graphics\data\CinematicTexture.cpp:372]: (style) Variable 'dy' is assigned a value that is never used.
  45. [graphics\data\CinematicTexture.cpp:365]: (style) Variable 'dx' is assigned a value that is never used.
  46. [graphics\data\Mesh.cpp:3182] -> [graphics\data\Mesh.cpp:3263]: (error, inconclusive) Possible null pointer dereference: ep - otherwise it is redundant to check it against null.
  47. [graphics\data\Mesh.cpp:3183] -> [graphics\data\Mesh.cpp:3263]: (error, inconclusive) Possible null pointer dereference: ep - otherwise it is redundant to check it against null.
  48. [graphics\data\Mesh.cpp:3184] -> [graphics\data\Mesh.cpp:3263]: (error, inconclusive) Possible null pointer dereference: ep - otherwise it is redundant to check it against null.
  49. [graphics\data\Mesh.cpp:3201] -> [graphics\data\Mesh.cpp:3263]: (error, inconclusive) Possible null pointer dereference: ep - otherwise it is redundant to check it against null.
  50. [graphics\data\Mesh.cpp:3202] -> [graphics\data\Mesh.cpp:3263]: (error, inconclusive) Possible null pointer dereference: ep - otherwise it is redundant to check it against null.
  51. [graphics\data\Mesh.cpp:3203] -> [graphics\data\Mesh.cpp:3263]: (error, inconclusive) Possible null pointer dereference: ep - otherwise it is redundant to check it against null.
  52. [graphics\data\MeshManipulation.cpp:823] -> [graphics\data\MeshManipulation.cpp:825]: (error) Possible null pointer dereference: io - otherwise it is redundant to check it against null.
  53. [graphics\data\MeshManipulation.cpp:770]: (style) The scope of the variable 'result2' can be reduced.
  54. [graphics\effects\DrawEffects.cpp:301] -> [graphics\effects\DrawEffects.cpp:297]: (style) Found duplicate branches for 'if' and 'else'.
  55. [graphics\image\Image.cpp:1000]: (style) C-style pointer casting
  56. [graphics\image\Image.cpp:1001]: (style) C-style pointer casting
  57. [graphics\image\Image.cpp:935]: (style) The scope of the variable 'offset' can be reduced.
  58. [graphics\image\Image.cpp:920]: (style) struct or union member 'DXT5AlphaBlock::mAlpha0' is never used.
  59. [graphics\image\Image.cpp:921]: (style) struct or union member 'DXT5AlphaBlock::mAlpha1' is never used.
  60. [graphics\image\Image.cpp:922]: (style) struct or union member 'DXT5AlphaBlock::mRow' is never used.
  61. [graphics\image\stb_image.cpp:2265]: (style) The scope of the variable 'i' can be reduced.
  62. [graphics\image\stb_image.cpp:2265]: (style) The scope of the variable 'j' can be reduced.
  63. [graphics\image\stb_image.cpp:2684]: (style) The scope of the variable 'compress' can be reduced.
  64. [graphics\image\stb_image.cpp:3211]: (style) The scope of the variable 'count' can be reduced.
  65. [graphics\image\stb_image.cpp:3211]: (style) The scope of the variable 'len' can be reduced.
  66. [graphics\image\stb_image.cpp:3504]: (style) The scope of the variable 'i' can be reduced.
  67. [graphics\image\stb_image.cpp:4012]: (style) The scope of the variable 'scanline' can be reduced.
  68. [graphics\image\stb_image.cpp:4014]: (style) The scope of the variable 'len' can be reduced.
  69. [graphics\image\stb_image.cpp:4015]: (style) The scope of the variable 'count' can be reduced.
  70. [graphics\image\stb_image.cpp:4015]: (style) The scope of the variable 'value' can be reduced.
  71. [graphics\image\stb_image.cpp:4016]: (style) The scope of the variable 'k' can be reduced.
  72. [graphics\image\stb_image.cpp:4016]: (style) The scope of the variable 'c1' can be reduced.
  73. [graphics\image\stb_image.cpp:4016]: (style) The scope of the variable 'c2' can be reduced.
  74. [graphics\image\stb_image.cpp:4016]: (style) The scope of the variable 'z' can be reduced.
  75. [graphics\image\stb_image.cpp:3031]: (error) Memory leak: tga_data
  76. [graphics\image\stb_image.cpp:2546]: (style) Variable 'invalid_chunk' is assigned a value that is never used.
  77. [graphics\image\stb_image_write.cpp:441]: (error) Resource leak: f
  78. [graphics\particle\ParticleSystem.cpp:271] -> [graphics\particle\ParticleSystem.cpp:272]: (performance) Buffer 'cBuf' is being written before its old content has been used.
  79. [graphics\particle\ParticleSystem.cpp:334] -> [graphics\particle\ParticleSystem.cpp:338]: (performance) Variable 'vv1' is reassigned a value before the old one has been used.
  80. [graphics\spells\Spells02.cpp:259]: (style) Boolean result is used in bitwise operation. Clarify expression with parentheses.
  81. [graphics\spells\Spells02.cpp:307]: (style) Boolean result is used in bitwise operation. Clarify expression with parentheses.
  82. [graphics\spells\Spells04.cpp:394]: (style) The scope of the variable 'io' can be reduced.
  83. [graphics\spells\Spells04.cpp:415]: (style) The scope of the variable 'io' can be reduced.
  84. [graphics\spells\Spells04.cpp:435]: (style) The scope of the variable 'io' can be reduced.
  85. [graphics\spells\Spells04.cpp:465]: (style) The scope of the variable 'io' can be reduced.
  86. [graphics\spells\Spells04.cpp:486]: (style) The scope of the variable 'io' can be reduced.
  87. [graphics\spells\Spells04.cpp:506]: (style) The scope of the variable 'io' can be reduced.
  88. [graphics\texture\PackedTexture.cpp:140]: (style) The scope of the variable 'result' can be reduced.
  89. [gui\Interface.cpp:620]: (style) C-style pointer casting
  90. [gui\Interface.cpp:7476] -> [gui\Interface.cpp:7474]: (style) Found duplicate branches for 'if' and 'else'.
  91. [gui\Interface.cpp:944]: (style) The scope of the variable 'tTxtCombineDest' can be reduced.
  92. [gui\Interface.cpp:7101]: (style) Variable 'v' is assigned a value that is never used.
  93. [gui\Interface.cpp:620]: (error) Common realloc mistake: 'aiHalo' nulled but not freed upon failure
  94. [gui\MenuWidgets.cpp:462]: (style) Variable 'iPosMenuPrincipaleY' is assigned a value that is never used.
  95. [gui\MenuWidgets.cpp:1502]: (style) Variable 'fControlPosY' is assigned a value that is never used.
  96. [gui\MiniMap.cpp:204] -> [gui\MiniMap.cpp:208]: (error) Possible null pointer dereference: dat - otherwise it is redundant to check it against null.
  97. [gui\MiniMap.cpp:279]: (style) The scope of the variable 'FL2_SIZE' can be reduced.
  98. [gui\MiniMap.cpp:280]: (style) The scope of the variable 'FL2_LEFT' can be reduced.
  99. [gui\MiniMap.cpp:281]: (style) The scope of the variable 'FL2_RIGHT' can be reduced.
  100. [gui\MiniMap.cpp:282]: (style) The scope of the variable 'FL2_TOP' can be reduced.
  101. [gui\MiniMap.cpp:283]: (style) The scope of the variable 'FL2_BOTTOM' can be reduced.
  102. [gui\MiniMap.cpp:284]: (style) The scope of the variable 'FL2_PLAYERSIZE' can be reduced.
  103. [gui\MiniMap.cpp:286]: (style) The scope of the variable 'DECALY' can be reduced.
  104. [gui\MiniMap.cpp:287]: (style) The scope of the variable 'DECALX' can be reduced.
  105. [gui\MiniMap.cpp:213]: (warning) scanf without field width limits can crash with huge input data.
  106. [input\Input.cpp:225]: (style) Variable 'autoBackend' is assigned a value that is never used.
  107. [io\fs\FilesystemPOSIX.cpp:173]: (style) Checking if unsigned variable 'path_max' is less than zero.
  108. [io\fs\FilesystemWindows.cpp:254]: (style) C-style pointer casting
  109. [io\fs\FilesystemWindows.cpp:265]: (style) C-style pointer casting
  110. [io\fs\FilesystemWindows.cpp:289]: (style) C-style pointer casting
  111. [io\fs\FilesystemWindows.cpp:294]: (style) C-style pointer casting
  112. [io\fs\FilesystemWindows.cpp:301]: (style) C-style pointer casting
  113. [io\fs\FilesystemWindows.cpp:308]: (style) C-style pointer casting
  114. [io\fs\SystemPaths.cpp:94]: (style) The scope of the variable 'create_exists' can be reduced.
  115. [io\resource\PakReader.cpp:227]: (style) C-style pointer casting
  116. [io\resource\PakReader.cpp:269]: (style) C-style pointer casting
  117. [io\resource\PakReader.cpp:220]: (warning) Member variable 'BlastFileInBuffer::readbuf' is not initialized in the constructor.
  118. [physics\Anchors.cpp:1292] -> [physics\Anchors.cpp:1288]: (error, inconclusive) Possible null pointer dereference: ep - otherwise it is redundant to check it against null.
  119. [platform\Time.cpp:1]: (information) Skipping configuration 'ARX_HAVE_CLOCK_GETTIME;CLOCK_MONOTONIC' because it seems to be invalid. Use -D if you want to check it.
  120. [platform\crashhandler\CrashHandlerPOSIX.cpp:0]: (information) Too many #ifdef configurations - cppcheck only checks 12 of 13 configurations. Use --force to check all configurations.
  121. [platform\crashhandler\CrashHandlerPOSIX.cpp:1]: (information) Skipping configuration 'ARX_HAVE_PRCTL;PR_SET_NAME' because it seems to be invalid. Use -D if you want to check it.
  122. [platform\crashhandler\CrashHandlerPOSIX.cpp:1]: (information) Skipping configuration 'ARX_HAVE_PRCTL;PR_SET_PDEATHSIG;SIGTERM' because it seems to be invalid. Use -D if you want to check it.
  123. [platform\crashhandler\CrashHandlerPOSIX.cpp:1]: (information) Skipping configuration 'SIGABRT' because it seems to be invalid. Use -D if you want to check it.
  124. [platform\crashhandler\CrashHandlerPOSIX.cpp:1]: (information) Skipping configuration 'SIGBUS' because it seems to be invalid. Use -D if you want to check it.
  125. [platform\crashhandler\CrashHandlerPOSIX.cpp:1]: (information) Skipping configuration 'SIGFPE' because it seems to be invalid. Use -D if you want to check it.
  126. [platform\crashhandler\CrashHandlerPOSIX.cpp:1]: (information) Skipping configuration 'SIGILL' because it seems to be invalid. Use -D if you want to check it.
  127. [platform\crashhandler\CrashHandlerWindows.cpp:387]: (error) Uninitialized variable: bCreateProcess
  128. [platform\crashhandler\CrashHandlerWindows.cpp:1]: (information) Skipping configuration '_FPE_MULTIPLE_FAULTS' because it seems to be invalid. Use -D if you want to check it.
  129. [platform\crashhandler\CrashHandlerWindows.cpp:1]: (information) Skipping configuration '_FPE_MULTIPLE_TRAPS' because it seems to be invalid. Use -D if you want to check it.
  130. [scene\GameSound.cpp:826] -> [scene\GameSound.cpp:816]: (error, inconclusive) Possible null pointer dereference: position - otherwise it is redundant to check it against null.
  131. [scene\GameSound.cpp:1204]: (style) C-style pointer casting
  132. [scene\GameSound.cpp:847] -> [scene\GameSound.cpp:847]: (style) Same expression on both sides of '|'.
  133. [scene\GameSound.cpp:1131]: (error) Common realloc mistake: 'elems' nulled but not freed upon failure
  134. [scene\GameSound.cpp:1133]: (error) Common realloc mistake: 'numbers' nulled but not freed upon failure
  135. [scene\Interactive.cpp:2434]: (style) The scope of the variable 'bPass' can be reduced.
  136. [scene\Interactive.cpp:412]: (style) Boolean result is used in bitwise operation. Clarify expression with parentheses.
  137. [scene\Interactive.cpp:433]: (style) Boolean result is used in bitwise operation. Clarify expression with parentheses.
  138. [scene\Interactive.cpp:1618]: (style) Boolean result is used in bitwise operation. Clarify expression with parentheses.
  139. [scene\Interactive.cpp:513]: (error) Common realloc mistake: 'treatio' nulled but not freed upon failure
  140. [scene\Interactive.cpp:3475]: (performance) Prefer prefix ++/-- operators for non-primitive types.
  141. [scene\Interactive.cpp:3477]: (performance) Prefer prefix ++/-- operators for non-primitive types.
  142. [scene\Object.cpp:253]: (style) C-style pointer casting
  143. [scene\Object.cpp:656] -> [scene\Object.cpp:654]: (style) Found duplicate branches for 'if' and 'else'.
  144. [scene\Scene.cpp:469] -> [scene\Scene.cpp:498]: (error) Possible null pointer dereference: io - otherwise it is redundant to check it against null.
  145. [scene\Scene.cpp:479] -> [scene\Scene.cpp:498]: (error) Possible null pointer dereference: io - otherwise it is redundant to check it against null.
  146. [scene\Scene.cpp:486] -> [scene\Scene.cpp:498]: (error) Possible null pointer dereference: io - otherwise it is redundant to check it against null.
  147. [scene\Scene.cpp:2815]: (style) The scope of the variable 'x0' can be reduced.
  148. [scene\Scene.cpp:2816]: (style) The scope of the variable 'x1' can be reduced.
  149. [scene\Scene.cpp:2817]: (style) The scope of the variable 'z0' can be reduced.
  150. [scene\Scene.cpp:2818]: (style) The scope of the variable 'z1' can be reduced.
  151. [scene\Scene.cpp:2861]: (style) The scope of the variable 'lll' can be reduced.
  152. [scene\Scene.cpp:2975]: (style) Variable 'temp0' is assigned a value that is never used.
  153. [scene\Scene.cpp:129]: (warning) Member variable 'DynamicVertexBuffer::start' is not initialized in the constructor.
  154. [scene\Scene.cpp:129]: (warning) Member variable 'DynamicVertexBuffer::offset' is not initialized in the constructor.
  155. [scene\Scene.cpp:856]: (error) Common realloc mistake: 'RoomDraw' nulled but not freed upon failure
  156. [scene\Scene.cpp:1105]: (error) Common realloc mistake: 'RoomDrawList' nulled but not freed upon failure
  157. [script\ScriptedLang.cpp:553]: (performance, inconclusive) Technically the member function 'script::IfCommand::Operator::getName' can be static.
  158. [script\ScriptedLang.cpp:554]: (style, inconclusive) Technically the member function 'script::IfCommand::Operator::getOperator' can be const.
  159. [script\ScriptedLang.cpp:555]: (style, inconclusive) Technically the member function 'script::IfCommand::Operator::getType' can be const.
Steps to reproduce this issue
Nothing entered.

#1
icon_reply.pngReply
Comment posted by
 Daniel Scharrer
Jul 06, 03:38
Some of these problems have been fixed in the cleanup branch, others (that aren't false positives) will be fixed as time permits. I will generate up to date cppcheck, flawfinder and clang-analyzer logs at http://arx-libertatis.org/buildlogs/arx/branches/master/

Thanks for reporting this, but in the future please file individual bug reports (or send patches) for the actual problems.

The issue was updated with the following change(s):
  • This issue has been closed
  • The status has been updated, from New to Postponed.
  • The resolution has been updated, from Not determined to POSTPONED.
  • This issue's progression has been updated to 100 percent completed.