PVS-StudioWarnings

PVS-Studio warning V557 for OpenMS

Nov 20th, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.31 KB | None | 0 0
  1. static const Int CHANNELS_FOURPLEX[4][1];
  2. static const Int CHANNELS_EIGHTPLEX[8][1];
  3.  
  4. ExitCodes main_(int, const char **)
  5. {
  6.   ....
  7.   if (itraq_type == ItraqQuantifier::FOURPLEX)
  8.   {
  9.     for (Size i = 0; i < 4; ++i)
  10.     {
  11.       std::vector<std::pair<String, DoubleReal> > one_label;
  12.       one_label.push_back(std::make_pair<String, DoubleReal>(
  13.         String("Channel ") +
  14.           String(ItraqConstants::CHANNELS_FOURPLEX[i][0]),
  15.         DoubleReal(ItraqConstants::CHANNELS_FOURPLEX[i][0])));
  16.       labels.push_back(one_label);
  17.     }
  18.   }
  19.   else //ItraqQuantifier::EIGHTPLEX
  20.   {
  21.     for (Size i = 0; i < 8; ++i)
  22.     {
  23.       std::vector<std::pair<String, DoubleReal> > one_label;
  24.       one_label.push_back(std::make_pair<String, DoubleReal>(
  25.         String("Channel ") +
  26.           String(ItraqConstants::CHANNELS_FOURPLEX[i][0]),
  27.         DoubleReal(ItraqConstants::CHANNELS_FOURPLEX[i][0])));
  28.       labels.push_back(one_label);
  29.     }
  30.   }
  31.   ....
  32. }
  33.  
  34. This suspicious code was found in OpenMS project by PVS-Studio static code analyzer.
  35. Warning message is:
  36. V557 Array overrun is possible. The value of 'i' index could reach 7. itraqanalyzer.c 232
  37.  
  38. PVS-Studio is a static analyzer for detecting bugs in the source code of applications written in C, C++, C++11, C++/CX. Site: http://www.viva64.com/en/pvs-studio/
Advertisement
Add Comment
Please, Sign In to add comment