| Summary: | Incorrect format. Consider checking the third actual argument of the 'sprintf' function. The argument is expected to be not greater than 32-bit. defaultheprepattvalue.cc 183 | ||
|---|---|---|---|
| Product: | Geant4 | Reporter: | a.ramazani |
| Component: | visualization/HepRep | Assignee: | perl |
| Status: | RESOLVED WONTFIX | ||
| Severity: | minor | CC: | a.ramazani |
| Priority: | P5 | ||
| Version: | 9.6 | ||
| Hardware: | PC | ||
| OS: | Windows | ||
This version of the HepRep driver will soon be deprecated. Accordingly, we are not performing work on this version unless it is critical. Please use /vis/open HepRepFile instead. |
Incorrect format. Consider checking the third actual argument of the 'sprintf' function. The argument is expected to be not greater than 32-bit. defaultheprepattvalue.cc 183 string DefaultHepRepAttValue::getAsString(int64 i) { char buffer[40]; sprintf(buffer, CHEPREP_INT64_FORMAT, i); return buffer; } #define CHEPREP_INT64_FORMAT "%ld" correct : #define CHEPREP_INT64_FORMAT "%I64d" test: #include <stdio.h> int main() { long long i64=123456789012345LL; printf(" %I64d \n",i64); printf(" %ld \n",i64); } results: 123456789012345 -2045911175 I used The Best C++ static code analysis Tools "PVS-Studio 4.77" under Visual Studio 2012 to analyze the Geant4.9.6 code There is many warnings and performance optimization so I recommend using PVS-Studio http://files.viva64.com/beta/PVS-Studio_setup.exe Please correct me if I am wrong Thanks in Advance.