mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 12:03:02 +01:00
Backported CORE-6345: Server crashes on overflow of division result
This commit is contained in:
parent
4becedeb01
commit
fb6b36b028
@ -2003,10 +2003,6 @@ dsc* ArithmeticNode::divide2(const dsc* desc, impure_value* value) const
|
|||||||
|
|
||||||
SINT64 i1 = MOV_get_int64(&value->vlu_desc, nodScale - desc->dsc_scale);
|
SINT64 i1 = MOV_get_int64(&value->vlu_desc, nodScale - desc->dsc_scale);
|
||||||
|
|
||||||
// MIN_SINT64 / -1 = (MAX_SINT64 + 1), which overflows in SINT64.
|
|
||||||
if ((i1 == MIN_SINT64) && (i2 == -1))
|
|
||||||
ERR_post(Arg::Gds(isc_exception_integer_overflow));
|
|
||||||
|
|
||||||
// Scale the dividend by as many of the needed powers of 10 as possible
|
// Scale the dividend by as many of the needed powers of 10 as possible
|
||||||
// without causing an overflow.
|
// without causing an overflow.
|
||||||
int addl_scale = 2 * desc->dsc_scale;
|
int addl_scale = 2 * desc->dsc_scale;
|
||||||
@ -2036,6 +2032,10 @@ dsc* ArithmeticNode::divide2(const dsc* desc, impure_value* value) const
|
|||||||
++addl_scale;
|
++addl_scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MIN_SINT64 / -1 = (MAX_SINT64 + 1), which overflows in SINT64.
|
||||||
|
if ((i1 == MIN_SINT64) && (i2 == -1))
|
||||||
|
ERR_post(Arg::Gds(isc_exception_integer_overflow));
|
||||||
|
|
||||||
value->vlu_desc.dsc_dtype = dtype_int64;
|
value->vlu_desc.dsc_dtype = dtype_int64;
|
||||||
value->vlu_desc.dsc_length = sizeof(SINT64);
|
value->vlu_desc.dsc_length = sizeof(SINT64);
|
||||||
value->vlu_desc.dsc_scale = nodScale;
|
value->vlu_desc.dsc_scale = nodScale;
|
||||||
|
Loading…
Reference in New Issue
Block a user