Merge pull request #3 from Abioy/master

Remove some useless code and check array index before using it
This commit is contained in:
yuansx 2018-12-28 10:05:09 +08:00 committed by GitHub
commit 514baf8410
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 6 deletions

View File

@ -115,7 +115,7 @@ void StatReport::setReportInfo(const StatFPrx& statPrx,
_maxReportSize = iMaxReportSize;
}
vector<string> vtSetInfo = TC_Common::sepstr<string>(strSetDivision,".");
if (vtSetInfo.size()!=3 ||(vtSetInfo.size()==3&&(vtSetInfo[0]=="*"||vtSetInfo[1]=="*")))
if (vtSetInfo.size()!=3 ||(vtSetInfo[0]=="*"||vtSetInfo[1]=="*"))
{
_setArea= "";
_setID = "";
@ -210,7 +210,7 @@ bool StatReport::divison2SetInfo(const string& str, vector<string>& vtSetInfo)
{
vtSetInfo = TC_Common::sepstr<string>(str,".");
if (vtSetInfo.size() != 3 ||(vtSetInfo.size()==3&&(vtSetInfo[0]=="*"||vtSetInfo[1]=="*")))
if (vtSetInfo.size() != 3 ||(vtSetInfo[0]=="*"||vtSetInfo[1]=="*"))
{
TLOGERROR(__FUNCTION__ << ":" << __LINE__ << "|bad set name [" << str << endl);
return false;

View File

@ -485,7 +485,7 @@ string Tars2Cpp::generateH(const StructPtr& pPtr, const string& namespaceId) con
if (vPtr)
{
BuiltinPtr bPtr = BuiltinPtr::dynamicCast(vPtr->getTypePtr());
if (!bPtr || (bPtr && bPtr->kind() == Builtin::KindString)) //非内建类型或者string 类型不能memset
if (!bPtr || bPtr->kind() == Builtin::KindString) //非内建类型或者string 类型不能memset
{
continue;
}

View File

@ -199,7 +199,7 @@ void TC_Cgi::parseNormal(multimap<string, string> &mmpParams, const string& sBuf
if(iFlag == 0)
{
while ( (sBuffer[pos] != '=') && (pos < len) )
while ( (pos < len) && (sBuffer[pos] != '=') )
{
sTmp += (sBuffer[pos] == '+') ? ' ' : sBuffer[pos];
@ -208,7 +208,7 @@ void TC_Cgi::parseNormal(multimap<string, string> &mmpParams, const string& sBuf
}
else
{
while ( (sBuffer[pos] != '&') && (pos < len) )
while ( (pos < len) && (sBuffer[pos] != '&') )
{
sTmp += (sBuffer[pos] == '+') ? ' ' : sBuffer[pos];

View File

@ -319,7 +319,6 @@ string TC_ConfigDomain::reverse_parse(const string &s)
case '\t':
param += "\\t";
break;
break;
case '=':
param += "\\=";
break;