mirror of
https://github.com/zeek/zeek.git
synced 2025-10-03 07:08:19 +00:00

Integral/floating-point division/modulo by zero in C++ is undefined behavior, so to prevent such cases in a script from crashing Bro, they're now reported as an error (with script location information) and the event handler in which it occurred returns immediately.
36 lines
543 B
Text
36 lines
543 B
Text
# @TEST-EXEC: bro -b %INPUT >out 2>&1
|
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
|
|
|
|
event div_int(a: int, b: int)
|
|
{
|
|
print a / b;
|
|
}
|
|
|
|
event div_count(a: count, b: count)
|
|
{
|
|
print a / b;
|
|
}
|
|
|
|
event div_double(a: double, b: double)
|
|
{
|
|
print a / b;
|
|
}
|
|
|
|
event mod_int(a: int, b: int)
|
|
{
|
|
print a % b;
|
|
}
|
|
|
|
event mod_count(a: count, b: count)
|
|
{
|
|
print a % b;
|
|
}
|
|
|
|
event bro_init()
|
|
{
|
|
event div_int(10, 0);
|
|
event div_count(10, 0);
|
|
event div_double(10.0, 0.0);
|
|
event mod_int(10, 0);
|
|
event mod_count(10, 0);
|
|
}
|