]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TTherminator/Therminator/Parser.cxx
Fix Coverity
[u/mrichter/AliRoot.git] / TTherminator / Therminator / Parser.cxx
index 892935ef488c643d2c291ae174c9dd96f7de2dab..2c485d7c71b13e79743c28b5fda06c82c0ee0f79 100644 (file)
@@ -299,17 +299,22 @@ void Parser::ReadInput()
       if(str[0] == 's' && str[1] == 'e' && str[2] == '[')
        {
          // Reading in the decay channels
-         char *tLBrackert, *tFirstComma, *tSecondComma, *tThirdComma, *tRBracket;
+         char *tLBrackert=NULL, *tFirstComma=NULL, *tSecondComma=NULL, *tThirdComma=NULL, *tRBracket=NULL;
          
          tLBrackert = strchr(str,'[');
          tFirstComma = strchr(str,',');
+         if (!tFirstComma) exit(0);
          tSecondComma = strchr(tFirstComma+1,',');
+         if (!tSecondComma) exit(0);
          tThirdComma = strchr(tSecondComma+1,',');
+         if (!tThirdComma) exit(0);
          tRBracket = strchr(tThirdComma,']');
 
-         if (!(tLBrackert && tFirstComma && tSecondComma && tThirdComma && tRBracket))
+         if (!((tLBrackert != NULL) && (tFirstComma != NULL) && (tSecondComma != NULL) && ( tThirdComma != NULL) && (tRBracket!= NULL))) {
            PRINT_DEBUG_1("Malformed line!: " << str);
-         
+           exit(0);
+         }
+
          char *tFather = new char[tFirstComma-tLBrackert];
          strncpy(tFather, tLBrackert+1,   tFirstComma-tLBrackert-1);
          char *tDaughter1 = new char[tSecondComma-tFirstComma];
@@ -407,9 +412,13 @@ void Parser::ReadInput()
          char *tLBrackert, *tFirstComma, *tSecondComma, *tThirdComma, *tRBracket;
          
          tLBrackert = strchr(str,'[');
+         if (!tLBrackert) exit(0);
          tFirstComma = strchr(str,',');
+         if (!tFirstComma) exit(0);
          tSecondComma = strchr(tFirstComma+1,',');
+         if (!tSecondComma) exit(0);
          tThirdComma = strchr(tSecondComma+1,',');
+         if (!tThirdComma) exit(0);
          tRBracket = strchr(tThirdComma,']');
          if (!(tLBrackert && tFirstComma && tSecondComma && tThirdComma && tRBracket))
            PRINT_DEBUG_1("Malformed line!: " << str);