Fixed #5643 (crash on address-of-operator& in condition) as suggested by serval2412
This commit is contained in:
parent
e19129a409
commit
25b1f2f541
|
@ -264,6 +264,8 @@ static bool isOverlappingCond(const Token * const cond1, const Token * const con
|
||||||
if (cond1->str() == "&" && cond1->astOperand1() && cond2->astOperand2()) {
|
if (cond1->str() == "&" && cond1->astOperand1() && cond2->astOperand2()) {
|
||||||
const Token *expr1 = cond1->astOperand1();
|
const Token *expr1 = cond1->astOperand1();
|
||||||
const Token *num1 = cond1->astOperand2();
|
const Token *num1 = cond1->astOperand2();
|
||||||
|
if (!num1) // unary operator&
|
||||||
|
return false;
|
||||||
if (!num1->isNumber())
|
if (!num1->isNumber())
|
||||||
std::swap(expr1,num1);
|
std::swap(expr1,num1);
|
||||||
if (!num1->isNumber() || MathLib::isNegative(num1->str()))
|
if (!num1->isNumber() || MathLib::isNegative(num1->str()))
|
||||||
|
|
|
@ -218,6 +218,13 @@ private:
|
||||||
" if (y==1) {}\n"
|
" if (y==1) {}\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// no crash on unary operator& (#5643)
|
||||||
|
check("SdrObject* ApplyGraphicToObject() {\n"
|
||||||
|
" if (&rHitObject) {}\n"
|
||||||
|
" else if (rHitObject.IsClosedObj() && !&rHitObject) { }\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void mismatchingBitAnd() {
|
void mismatchingBitAnd() {
|
||||||
|
|
Loading…
Reference in New Issue