You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2015/07/11 14:52:43 UTC
[09/12] lucy-clownfish git commit: Check for overflow when converting
Float64 to Int64
Check for overflow when converting Float64 to Int64
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/8d379ef2
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/8d379ef2
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/8d379ef2
Branch: refs/heads/master
Commit: 8d379ef2fd0ce9694726be929cdec6ebeab3982f
Parents: b1b44e0
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sun May 24 15:19:11 2015 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Thu Jul 9 16:34:00 2015 +0200
----------------------------------------------------------------------
runtime/core/Clownfish/Num.c | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/8d379ef2/runtime/core/Clownfish/Num.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Num.c b/runtime/core/Clownfish/Num.c
index 3575fea..f310fd9 100644
--- a/runtime/core/Clownfish/Num.c
+++ b/runtime/core/Clownfish/Num.c
@@ -157,6 +157,9 @@ Float64_To_F64_IMP(Float64 *self) {
int64_t
Float64_To_I64_IMP(Float64 *self) {
+ if (self->value < -POW_2_63 || self->value >= POW_2_63) {
+ THROW(ERR, "Float64 out of range: %f64", self->value);
+ }
return (int64_t)self->value;
}