[Gmsh] Mistakes found in the GMSH source code

Christophe Geuzaine cgeuzaine at ulg.ac.be
Thu Apr 11 12:26:01 CEST 2013


Hi Guy - Thanks for the feedback! Most should now be fixed in svn.


On 10 Apr 2013, at 15:10, Guy Vaessen <guy.vaessen at gmail.com> wrote:

> I did a check (using cppcheck) of the GMSH source code and cppcheck reported these errors:
> 
> [gmsh-2.7.1-svn-20130409-source\Geo\MQuadrangle.h:453]: (error) Array 't[3]' accessed at index 3, which is out of bounds.
> [gmsh-2.7.1-svn-20130409-source\Geo\MQuadrangle.h:455]: (error) Array 't[3]' accessed at index 3, which is out of bounds.
> [gmsh-2.7.1-svn-20130409-source\Mesh\meshGFaceBDS.cpp:88]: (error) Array 'GP[9]' accessed at index 9, which is out of bounds.
> [gmsh-2.7.1-svn-20130409-source\Mesh\meshGFaceBDS.cpp:89]: (error) Array 'GP[9]' accessed at index 9, which is out of bounds.
> [gmsh-2.7.1-svn-20130409-source\Mesh\meshGFaceBDS.cpp:90]: (error) Array 'GP[9]' accessed at index 9, which is out of bounds.
> [gmsh-2.7.1-svn-20130409-source\Mesh\DivideAndConquer.cpp:739]: (error) Uninitialized variable: E (first iteration of for-loop E is undefined)
> [gmsh-2.7.1-svn-20130409-source\Mesh\directions3D.cpp:1525]: (error) Uninitialized variable: val (if HAVE_ANN is undefined)
> [gmsh-2.7.1-svn-20130409-source\Mesh\meshGFaceRecombine.cpp:109]: (error) Uninitialized variable: a
> [gmsh-2.7.1-svn-20130409-source\Mesh\meshGFaceRecombine.cpp:109]: (error) Buffer is accessed out of bounds: a
> [gmsh-2.7.1-svn-20130409-source\Mesh\meshGFaceOptimize.cpp:2462]: (error) Iterator 'itsz' used after element has been erased.
> [gmsh-2.7.1-svn-20130409-source\contrib\Chaco\eigen\bisect.c:98]: (error) Uninitialized variable: ii
> [gmsh-2.7.1-svn-20130409-source\contrib\kbipack\gmp_matrix.cpp:184]: (error) Memory leak: new_matrix
> [gmsh-2.7.1-svn-20130409-source\contrib\kbipack\gmp_normal_form.cpp:80]: (error) Memory leak: new_nf
> [gmsh-2.7.1-svn-20130409-source\contrib\mmg3d\build\sources\outqua.c:220]: (error) Buffer is accessed out of bounds: his01
> [gmsh-2.7.1-svn-20130409-source\contrib\mmg3d\build\sources\simu710.c:56]: (error) Buffer is accessed out of bounds: qual
> [gmsh-2.7.1-svn-20130409-source\contrib\mmg3d\build\sources\ratio.c:241]: (error) Resource leak: inm (file is not closed before return)
> 
> I hope this helps!
> 
> Best Regards,
> 
> Guy
> 
> cppcheck also reported the following issues but I didn't have time to check these:
> 
> [gmsh-2.7.1-svn-20130409-source\Common\OpenFile.cpp:277]: (error) Resource leak: fp
> [gmsh-2.7.1-svn-20130409-source\Common\OpenFile.cpp:503]: (error) Resource leak: fp
> [gmsh-2.7.1-svn-20130409-source\Fltk\projectionEditor.cpp:470]: (error) Resource leak: fp
> [gmsh-2.7.1-svn-20130409-source\Geo\GFaceCompound.cpp:283] -> [gmsh-2.7.1-svn-20130409-source\Geo\GFaceCompound.cpp:288]: (error) Iterator 'ite' used after element has been erased.
> [gmsh-2.7.1-svn-20130409-source\Geo\GModelIO_DIFF.cpp:60]: (error) Resource leak: fp
> [gmsh-2.7.1-svn-20130409-source\Geo\GModelIO_GEOM.cpp:35]: (error) Resource leak: fp
> [gmsh-2.7.1-svn-20130409-source\Geo\GModelIO_MESH.cpp:39]: (error) Resource leak: fp
> [gmsh-2.7.1-svn-20130409-source\Geo\GModelIO_P3D.cpp:21]: (error) Resource leak: fp
> [gmsh-2.7.1-svn-20130409-source\Geo\GModelIO_PLY.cpp:86]: (error) Resource leak: fp
> [gmsh-2.7.1-svn-20130409-source\Geo\GModelIO_POS.cpp:68]: (error) Resource leak: fp
> [gmsh-2.7.1-svn-20130409-source\Geo\GModelIO_STL.cpp:29]: (error) Resource leak: fp
> [gmsh-2.7.1-svn-20130409-source\Geo\GModelIO_VTK.cpp:110]: (error) Resource leak: fp
> [gmsh-2.7.1-svn-20130409-source\Geo\Geo.cpp:2513] -> [gmsh-2.7.1-svn-20130409-source\Geo\Geo.cpp:2512]: (error) Possible null pointer dereference: c - otherwise it is redundant to check it against null.
> [gmsh-2.7.1-svn-20130409-source\Graphics\gl2gif.cpp:555]: (error) Memory leak: bv
> [gmsh-2.7.1-svn-20130409-source\Mesh\Generator.cpp:418]: (error) Resource leak: statreport
> [gmsh-2.7.1-svn-20130409-source\Mesh\QuadTriExtruded2D.cpp:150] -> [gmsh-2.7.1-svn-20130409-source\Mesh\QuadTriExtruded2D.cpp:153]: (error) Possible null pointer dereference: adj_region - otherwise it is redundant to check it against null.
> [gmsh-2.7.1-svn-20130409-source\Mesh\QuadTriExtruded2D.cpp:555] -> [gmsh-2.7.1-svn-20130409-source\Mesh\QuadTriExtruded2D.cpp:557]: (error) Possible null pointer dereference: root_source - otherwise it is redundant to check it against null.
> [gmsh-2.7.1-svn-20130409-source\Mesh\meshGFace.cpp:1042]: (error) Memory leak: _error
> [gmsh-2.7.1-svn-20130409-source\Mesh\meshGFaceOptimize.cpp:938]: (error) Resource leak: f3
> [gmsh-2.7.1-svn-20130409-source\Mesh\meshGFaceRecombine.cpp:3710]: (error) Memory leak: numAngle
> [gmsh-2.7.1-svn-20130409-source\Mesh\meshGFaceRecombine.cpp:3710]: (error) Memory leak: qualAngle
> [gmsh-2.7.1-svn-20130409-source\Plugin\MakeSimplex.cpp:48]: (error) Memory leak: valNew
> [gmsh-2.7.1-svn-20130409-source\Post\PViewDataGModelIO.cpp:220]: (error) Resource leak: fp
> [gmsh-2.7.1-svn-20130409-source\Post\PViewDataGModelIO.cpp:721]: (error) Dangerous usage of c_str(). The value returned by c_str() is invalid after this call.
> [gmsh-2.7.1-svn-20130409-source\Post\PViewDataIO.cpp:24]: (error) Resource leak: fp
> [gmsh-2.7.1-svn-20130409-source\Post\PViewDataListIO.cpp:394]: (error) Resource leak: fp
> [gmsh-2.7.1-svn-20130409-source\Post\PViewIO.cpp:95]: (error) Resource leak: fp
> [gmsh-2.7.1-svn-20130409-source\Post\PViewVertexArrays.cpp:1271]: (error) Memory leak: x2
> [gmsh-2.7.1-svn-20130409-source\Post\PViewVertexArrays.cpp:1271]: (error) Memory leak: v2
> [gmsh-2.7.1-svn-20130409-source\Solver\elasticitySolver.cpp:152]: (error) Resource leak: f
> [gmsh-2.7.1-svn-20130409-source\Solver\linearSystemCSR.cpp:191]: (error) Memory leak: v
> [gmsh-2.7.1-svn-20130409-source\contrib\Chaco\submain\submain.c:132] -> [gmsh-2.7.1-svn-20130409-source\contrib\Chaco\submain\submain.c:130]: (error) Possible null pointer dereference: outfile - otherwise it is redundant to check it against null.
> [gmsh-2.7.1-svn-20130409-source\contrib\Netgen\libsrc\csg\singularref.cpp:180] -> [gmsh-2.7.1-svn-20130409-source\contrib\Netgen\libsrc\csg\singularref.cpp:182]: (error) Possible null pointer dereference: tansol - otherwise it is redundant to check it against null.
> [gmsh-2.7.1-svn-20130409-source\contrib\Netgen\libsrc\gprim\adtree.cpp:90]: (error) Memory leak: bmin
> [gmsh-2.7.1-svn-20130409-source\contrib\Netgen\libsrc\gprim\adtree.cpp:90]: (error) Memory leak: bmax
> [gmsh-2.7.1-svn-20130409-source\contrib\Netgen\libsrc\gprim\adtree.cpp:635] -> [gmsh-2.7.1-svn-20130409-source\contrib\Netgen\libsrc\gprim\adtree.cpp:638]: (error) Possible null pointer dereference: node - otherwise it is redundant to check it against null.
> [gmsh-2.7.1-svn-20130409-source\contrib\Netgen\libsrc\gprim\adtree.cpp:1140] -> [gmsh-2.7.1-svn-20130409-source\contrib\Netgen\libsrc\gprim\adtree.cpp:1143]: (error) Possible null pointer dereference: node - otherwise it is redundant to check it against null.
> [gmsh-2.7.1-svn-20130409-source\contrib\Netgen\libsrc\gprim\adtree.cpp:1401] -> [gmsh-2.7.1-svn-20130409-source\contrib\Netgen\libsrc\gprim\adtree.cpp:1404]: (error) Possible null pointer dereference: node - otherwise it is redundant to check it against null.
> [gmsh-2.7.1-svn-20130409-source\contrib\Netgen\libsrc\gprim\adtree.cpp:1936] -> [gmsh-2.7.1-svn-20130409-source\contrib\Netgen\libsrc\gprim\adtree.cpp:1939]: (error) Possible null pointer dereference: node - otherwise it is redundant to check it against null.
> [gmsh-2.7.1-svn-20130409-source\contrib\Netgen\libsrc\meshing\improve2gen.cpp:450]: (error) Memory leak: r1
> [gmsh-2.7.1-svn-20130409-source\contrib\Netgen\libsrc\occ\occpkg.cpp:514]: (error) Dangerous usage of c_str(). The value returned by c_str() is invalid after this call.
> [gmsh-2.7.1-svn-20130409-source\contrib\Netgen\libsrc\stlgeom\stlgeom.cpp:100]: (error) Reference to temporary returned.
> [gmsh-2.7.1-svn-20130409-source\contrib\bamg\bamglib\MeshQuad.cpp:931]: (error) Mismatching allocation and deallocation: newedges
> [gmsh-2.7.1-svn-20130409-source\contrib\blossom\concorde97\CUT\cut_st.c:678] -> [gmsh-2.7.1-svn-20130409-source\contrib\blossom\concorde97\CUT\cut_st.c:680]: (error) Possible null pointer dereference: q - otherwise it is redundant to check it against null.
> [gmsh-2.7.1-svn-20130409-source\contrib\blossom\concorde97\EDGEGEN\edgegen.c:1389] -> [gmsh-2.7.1-svn-20130409-source\contrib\blossom\concorde97\EDGEGEN\edgegen.c:1390]: (error) Possible null pointer dereference: elist - otherwise it is redundant to check it against null.
> [gmsh-2.7.1-svn-20130409-source\contrib\blossom\concorde97\EDGEGEN\edgegen.c:1394] -> [gmsh-2.7.1-svn-20130409-source\contrib\blossom\concorde97\EDGEGEN\edgegen.c:1395]: (error) Possible null pointer dereference: elen - otherwise it is redundant to check it against null.
> [gmsh-2.7.1-svn-20130409-source\contrib\blossom\concorde97\FMATCH\fm_main.c:507]: (error) Resource leak: out
> [gmsh-2.7.1-svn-20130409-source\contrib\blossom\concorde97\FMATCH\fm_main.c:527]: (error) Resource leak: out
> [gmsh-2.7.1-svn-20130409-source\contrib\blossom\concorde97\FMATCH\fm_main.c:549]: (error) Resource leak: out
> [gmsh-2.7.1-svn-20130409-source\contrib\blossom\concorde97\TSP\branch.c:1264]: (error) Possible null pointer dereference: cliques
> [gmsh-2.7.1-svn-20130409-source\contrib\blossom\concorde97\TSP\prob_io.c:1408] -> [gmsh-2.7.1-svn-20130409-source\contrib\blossom\concorde97\TSP\prob_io.c:1410]: (error) Possible null pointer dereference: adjspace - otherwise it is redundant to check it against null.
> [gmsh-2.7.1-svn-20130409-source\contrib\blossom\concorde97\XSTUFF\Xblock.c:556] -> [gmsh-2.7.1-svn-20130409-source\contrib\blossom\concorde97\XSTUFF\Xblock.c:555]: (error) Possible null pointer dereference: v - otherwise it is redundant to check it against null.
> [gmsh-2.7.1-svn-20130409-source\contrib\blossom\concorde97\XSTUFF\Xnecklac.c:726] -> [gmsh-2.7.1-svn-20130409-source\contrib\blossom\concorde97\XSTUFF\Xnecklac.c:729]: (error) Possible null pointer dereference: front - otherwise it is redundant to check it against null.
> [gmsh-2.7.1-svn-20130409-source\contrib\mmg3d\build\sources\inout.c:1228]: (error) Resource leak: inm
> [gmsh-2.7.1-svn-20130409-source\contrib\mmg3d\build\sources\mmg3d.c:293]: (error) fflush() called on input stream 'stdin' results in undefined behaviour.
> [gmsh-2.7.1-svn-20130409-source\contrib\mmg3d\build\sources\mmg3d.c:302]: (error) fflush() called on input stream 'stdin' results in undefined behaviour.
> [gmsh-2.7.1-svn-20130409-source\contrib\mmg3d\build\sources\mmg3d.c:322]: (error) fflush() called on input stream 'stdin' results in undefined behaviour.
> [gmsh-2.7.1-svn-20130409-source\contrib\mpeg_encode\libpnmrw.cpp:96]: (error) Memory leak: its
> [gmsh-2.7.1-svn-20130409-source\contrib\mpeg_encode\libpnmrw.cpp:1146]: (error) Memory leak: chv
> [gmsh-2.7.1-svn-20130409-source\contrib\mpeg_encode\libpnmrw.cpp:659]: (error) Memory leak: grayrow
> [gmsh-2.7.1-svn-20130409-source\contrib\mpeg_encode\param.cpp:532]: (error) Resource leak: fpointer
> [gmsh-2.7.1-svn-20130409-source\contrib\mpeg_encode\param.cpp:1178]: (error) Resource leak: jmovie
> [gmsh-2.7.1-svn-20130409-source\contrib\mpeg_encode\psearch.cpp:911]: (error) Memory leak: columnTotals
> [gmsh-2.7.1-svn-20130409-source\contrib\mpeg_encode\psearch.cpp:957]: (error) Memory leak: columnTotals
> [gmsh-2.7.1-svn-20130409-source\contrib\mpeg_encode\psearch.cpp:1003]: (error) Memory leak: columnTotals
> [gmsh-2.7.1-svn-20130409-source\contrib\mpeg_encode\readframe.cpp:369]: (error) Mismatching allocation and deallocation: ifp
> [gmsh-2.7.1-svn-20130409-source\contrib\mpeg_encode\specifics.cpp:175]: (error) Resource leak: specificsFP
> [gmsh-2.7.1-svn-20130409-source\contrib\voro++\examples\extra\irregular.cc:61]: (error) Instance of 'wall_initial_shape' object is destroyed immediately.
> [gmsh-2.7.1-svn-20130409-source\contrib\voro++\examples\no_release\finite_sys.cc:71]: (error) Instance of 'wall_initial_shape' object is destroyed immediately.
> [gmsh-2.7.1-svn-20130409-source\contrib\voro++\examples\no_release\import_freeman.cc:50]: (error) Resource leak: outputFile
> [gmsh-2.7.1-svn-20130409-source\contrib\voro++\zeo\network.cc:103]: (error) Resource leak: fp
> [gmsh-2.7.1-svn-20130409-source\utils\converters\brl-cad\printing.h:13]: (error) Mismatching allocation and deallocation: Indent::buffer
> [gmsh-2.7.1-svn-20130409-source\utils\solvers\c++\onelab.h:241]: (error) Resource leak: fp
> _______________________________________________
> gmsh mailing list
> gmsh at geuz.org
> http://www.geuz.org/mailman/listinfo/gmsh

-- 
Prof. Christophe Geuzaine
University of Liege, Electrical Engineering and Computer Science 
http://www.montefiore.ulg.ac.be/~geuzaine