Prevent crash on modulo by zero
1937095
"Prevent crash on division by zero" fixed a crash when attempting
a division by zero using the / operator in a dts. However, it missed the
precisely equivalent crash with the % (modulus) operator. This patch fixes
the oversight.
Reported-by: Anton Blanchard <anton@samba.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
main
parent
b43345039b
commit
b06e55c88b
10
dtc-parser.y
10
dtc-parser.y
|
@ -419,7 +419,15 @@ integer_mul:
|
||||||
$$ = 0;
|
$$ = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
| integer_mul '%' integer_unary { $$ = $1 % $3; }
|
| integer_mul '%' integer_unary
|
||||||
|
{
|
||||||
|
if ($3 != 0) {
|
||||||
|
$$ = $1 % $3;
|
||||||
|
} else {
|
||||||
|
ERROR(&@$, "Division by zero");
|
||||||
|
$$ = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
| integer_unary
|
| integer_unary
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/dts-v1/;
|
/dts-v1/;
|
||||||
|
|
||||||
/ {
|
/ {
|
||||||
prop = < (1/0) >;
|
prop-div = < (1/0) >;
|
||||||
|
prop-mod = < (1%0) >;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue