From 7bbfa88ddd51bff79b7a9d34e3f4b8bf5a7665b3 Mon Sep 17 00:00:00 2001 From: Charles Villard Date: Fri, 10 Jun 2022 15:07:45 +0200 Subject: [PATCH] Fix compilation warnings to error, mostly use-after-free and maybe uninitialized. --- include/ext_stl/fifo.h | 3 +++ src/TpMMPD/DeformAnalyse.cpp | 2 +- src/TpMMPD/TiePByMesh/TaskCorrel/cAppliTaskCorrel.cpp | 2 +- src/uti_phgrm/GraphCut/MaxFlow/graph.cpp | 4 ++++ src/util/regex.cpp | 2 +- 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/ext_stl/fifo.h b/include/ext_stl/fifo.h index a542df9e52..2eb5315233 100755 --- a/include/ext_stl/fifo.h +++ b/include/ext_stl/fifo.h @@ -197,6 +197,9 @@ template class ElFifo void incr_capa() { + if (_capa == 0) + _capa = 1; + Type * NewTab = new Type [2*_capa]; for (INT kk=0; kk<_nb ; kk++) NewTab[kk] = _tab[(kk+_begin)%_capa]; diff --git a/src/TpMMPD/DeformAnalyse.cpp b/src/TpMMPD/DeformAnalyse.cpp index ef47c79b2a..d7a3b41dab 100755 --- a/src/TpMMPD/DeformAnalyse.cpp +++ b/src/TpMMPD/DeformAnalyse.cpp @@ -76,7 +76,7 @@ int DeformAnalyse_main (int argc, char ** argv) // 3. get the vector PerResidu ifstream aPR((aDir + aOut1).c_str()); - char *aPerR; + char *aPerR{nullptr}; if(aPR) { std::string aLine; diff --git a/src/TpMMPD/TiePByMesh/TaskCorrel/cAppliTaskCorrel.cpp b/src/TpMMPD/TiePByMesh/TaskCorrel/cAppliTaskCorrel.cpp index 20263756eb..ce8e6ef019 100755 --- a/src/TpMMPD/TiePByMesh/TaskCorrel/cAppliTaskCorrel.cpp +++ b/src/TpMMPD/TiePByMesh/TaskCorrel/cAppliTaskCorrel.cpp @@ -116,7 +116,7 @@ void cAppliTaskCorrel::ReadXMLMesurePts(string aGCPMesureXML, vector & aMes = iT1->OneMesureAF1I(); string aNameIm = iT1->NameIm(); cout<Name()) diff --git a/src/uti_phgrm/GraphCut/MaxFlow/graph.cpp b/src/uti_phgrm/GraphCut/MaxFlow/graph.cpp index f0202a9b7a..352dc91662 100755 --- a/src/uti_phgrm/GraphCut/MaxFlow/graph.cpp +++ b/src/uti_phgrm/GraphCut/MaxFlow/graph.cpp @@ -58,6 +58,7 @@ template flow = 0; } +/* template void Graph::reallocate_nodes(int num) { @@ -86,7 +87,9 @@ template } } } +*/ +/* template void Graph::reallocate_arcs() { @@ -117,5 +120,6 @@ template } } } +*/ #include "instances.inc" diff --git a/src/util/regex.cpp b/src/util/regex.cpp index e8b0b2f255..b36df743e3 100755 --- a/src/util/regex.cpp +++ b/src/util/regex.cpp @@ -106,7 +106,7 @@ cElRegex::cElRegex(const std::string & aNameExprIn,int aNbMatchMax,int aCFlag,bo if (! IsOk()) return; - regmatch_t aMatch; + regmatch_t aMatch{}; mVMatch.reserve(aNbMatchMax); for (int aK=0; aK