From a21f04aec5aee0b7972fc72318807a2f156de467 Mon Sep 17 00:00:00 2001 From: Stefan Vigerske Date: Mon, 12 Aug 2024 09:04:57 +0200 Subject: [PATCH] add terminating null-bytes to string initialization via char array --- CHANGELOG | 1 + src/lpi/lpi_cpx.c | 1 + src/lpi/lpi_grb.c | 2 +- src/lpi/lpi_spx1.cpp | 4 ++-- src/lpi/lpi_spx2.cpp | 6 +++--- src/lpi/lpi_xprs.c | 2 +- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 02a9bb6d80..bfaa16fa32 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,7 @@ Fixed bugs - maintain definition of artificial integral variables in xor constraints to avoid invalidations of conflict constraints - free childless nodes only after the deactivation of the old focus path in treeSwitchPath() of tree.c - only normalize rows for column norm evaluations in heur_shiftandpropagate.c to avoid unscaled violations +- fixed that names and description of the LPI's were not null-terminated Performance improvements ------------------------ diff --git a/src/lpi/lpi_cpx.c b/src/lpi/lpi_cpx.c index 3f6238b7dd..ad3b78b9a6 100644 --- a/src/lpi/lpi_cpx.c +++ b/src/lpi/lpi_cpx.c @@ -1022,6 +1022,7 @@ static const char cpxname[]= {'C', 'P', 'L', 'E', 'X', ' ', #else (CPX_VERSION / 100) + '0', '.', ((CPX_VERSION % 100) / 10) + '0', '.', (CPX_VERSION % 10) + '0', '.', CPX_SUBVERSION + '0' #endif + , '\0' }; diff --git a/src/lpi/lpi_grb.c b/src/lpi/lpi_grb.c index c05bf15fd2..e3452ba2f9 100644 --- a/src/lpi/lpi_grb.c +++ b/src/lpi/lpi_grb.c @@ -1249,7 +1249,7 @@ static const char grbname[] = {'G', 'u', 'r', 'o', 'b', 'i', ' ', #else (GRB_VERSION_MAJOR/10) + '0', (GRB_VERSION_MAJOR%10) + '0', /*lint !e778*/ #endif - '.', GRB_VERSION_MINOR + '0', '.', GRB_VERSION_TECHNICAL + '0'}; /*lint !e835*/ + '.', GRB_VERSION_MINOR + '0', '.', GRB_VERSION_TECHNICAL + '0', '\0'}; /*lint !e835*/ /**@name Miscellaneous Methods */ /**@{ */ diff --git a/src/lpi/lpi_spx1.cpp b/src/lpi/lpi_spx1.cpp index 4466048f14..566bfe7ca2 100644 --- a/src/lpi/lpi_spx1.cpp +++ b/src/lpi/lpi_spx1.cpp @@ -1634,9 +1634,9 @@ void invalidateSolution(SCIP_LPI* lpi) char* initSpxDesc( ); #if (SOPLEX_SUBVERSION > 0) - const static char spxname[20]= {'S', 'o', 'p', 'l', 'e', 'x', '1', ' ', SOPLEX_VERSION/100 + '0', '.', (SOPLEX_VERSION % 100)/10 + '0', '.', SOPLEX_VERSION % 10 + '0', '.', SOPLEX_SUBVERSION + '0'}; + const static char spxname[20]= {'S', 'o', 'p', 'l', 'e', 'x', '1', ' ', SOPLEX_VERSION/100 + '0', '.', (SOPLEX_VERSION % 100)/10 + '0', '.', SOPLEX_VERSION % 10 + '0', '.', SOPLEX_SUBVERSION + '0', '\0'}; #else - const static char spxname[20] = {'S', 'o', 'p', 'l', 'e', 'x', '1', ' ', SOPLEX_VERSION/100 + '0', '.', (SOPLEX_VERSION % 100)/10 + '0', '.', SOPLEX_VERSION % 10 + '0'}; + const static char spxname[20] = {'S', 'o', 'p', 'l', 'e', 'x', '1', ' ', SOPLEX_VERSION/100 + '0', '.', (SOPLEX_VERSION % 100)/10 + '0', '.', SOPLEX_VERSION % 10 + '0', '\0'}; #endif static char* spxdesc = initSpxDesc(); diff --git a/src/lpi/lpi_spx2.cpp b/src/lpi/lpi_spx2.cpp index b80b7ccb0e..dc0e96e627 100644 --- a/src/lpi/lpi_spx2.cpp +++ b/src/lpi/lpi_spx2.cpp @@ -974,9 +974,9 @@ void invalidateSolution(SCIP_LPI* lpi) */ #if (SOPLEX_SUBVERSION > 0) - const static char spxname[20] = {'S', 'o', 'p', 'l', 'e', 'x', ' ', SOPLEX_VERSION/100 + '0', '.', (SOPLEX_VERSION % 100)/10 + '0', '.', SOPLEX_VERSION % 10 + '0', '.', SOPLEX_SUBVERSION + '0'}; + const static char spxname[20] = {'S', 'o', 'p', 'l', 'e', 'x', ' ', SOPLEX_VERSION/100 + '0', '.', (SOPLEX_VERSION % 100)/10 + '0', '.', SOPLEX_VERSION % 10 + '0', '.', SOPLEX_SUBVERSION + '0', '\0'}; #else - const static char spxname[20] = {'S', 'o', 'p', 'l', 'e', 'x', ' ', SOPLEX_VERSION/100 + '0', '.', (SOPLEX_VERSION % 100)/10 + '0', '.', SOPLEX_VERSION % 10 + '0'}; + const static char spxname[20] = {'S', 'o', 'p', 'l', 'e', 'x', ' ', SOPLEX_VERSION/100 + '0', '.', (SOPLEX_VERSION % 100)/10 + '0', '.', SOPLEX_VERSION % 10 + '0', '\0'}; #endif const static char spxdesc[200] = {'L', 'i', 'n', 'e', 'a', 'r', ' ', 'P', 'r', 'o', 'g', 'r', 'a', 'm', 'm', 'i', 'n', 'g', ' ', 'S', 'o', 'l', 'v', 'e', 'r', ' ' , 'd', 'e', 'v', 'e', 'l', 'o', 'p', 'e', 'd', @@ -989,7 +989,7 @@ const static char spxdesc[200] = {'L', 'i', 'n', 'e', 'a', 'r', ' ', 'P', 'r', ' ', '[', 'G', 'i', 't', 'H', 'a', 's', 'h', ':', ' ', getGitHash()[0], getGitHash()[1], getGitHash()[2], getGitHash()[3], getGitHash()[4], getGitHash()[5], getGitHash()[6], getGitHash()[7], - ']'}; + ']', '\0'}; /**@name Miscellaneous Methods */ /**@{ */ diff --git a/src/lpi/lpi_xprs.c b/src/lpi/lpi_xprs.c index 31674c40b8..dcd48d7bf8 100644 --- a/src/lpi/lpi_xprs.c +++ b/src/lpi/lpi_xprs.c @@ -655,7 +655,7 @@ void invalidateSolution( #ifdef _Thread_local static _Thread_local char xprsname[100]; #else -static char xprsname[] = {'X', 'p', 'r', 'e', 's', 's', ' ', '0' + XPVERSION / 10, '0' + XPVERSION % 10}; +static char xprsname[] = {'X', 'p', 'r', 'e', 's', 's', ' ', '0' + XPVERSION / 10, '0' + XPVERSION % 10, '\0'}; #endif /** gets name and version of LP solver */ const char* SCIPlpiGetSolverName(