avoid crash in checkother:wrongPipeParameterSize when a pointer with unknown size is provided.

This commit is contained in:
Ettl Martin 2013-04-11 14:22:22 +02:00
parent 33cfc1a52e
commit e03a3946d0
2 changed files with 10 additions and 1 deletions

View File

@ -524,7 +524,7 @@ void CheckOther::checkPipeParameterSize()
const Variable *var = varTok->variable();
MathLib::bigint dim;
if (var && (var->isArray() || var->isPointer()) && ((dim=var->dimension(0U)) < 2)) {
if (var && (var->isArray() || var->isPointer()) && !var->isArgument() && ((dim=var->dimension(0U)) < 2)) {
const std::string strDim = MathLib::longToString(dim);
checkPipeParameterSizeError(varTok,varTok->str(), strDim);
}

View File

@ -6114,6 +6114,15 @@ private:
" }\n"
"}",NULL,false,false,true);
ASSERT_EQUALS("", errout.str());
// avoid crash with pointer variable
check("void foo (int* arrayPtr)\n"
"{\n"
" if (pipe (arrayPtr) < 0)\n"
" {}\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void checkCastIntToCharAndBack() { // #160