[opencv] 40/251: core: forbid conversion real->int in some cases in FileStorage

Nobuhiro Iwamatsu iwamatsu at moszumanska.debian.org
Sun Aug 27 23:27:22 UTC 2017


This is an automated email from the git hooks/post-receive script.

iwamatsu pushed a commit to annotated tag 3.3.0
in repository opencv.

commit 5b833db558a670bd8b5d501f4070dfe1cacc63a9
Author: Vladislav Sovrasov <sovrasov.vlad at gmail.com>
Date:   Fri Jun 23 17:03:13 2017 +0300

    core: forbid conversion real->int in some cases in FileStorage
---
 modules/core/src/persistence.cpp | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/modules/core/src/persistence.cpp b/modules/core/src/persistence.cpp
index ca4615e..90ebb77 100644
--- a/modules/core/src/persistence.cpp
+++ b/modules/core/src/persistence.cpp
@@ -7374,22 +7374,21 @@ size_t FileNode::size() const
 void read(const FileNode& node, int& value, int default_value)
 {
     value = !node.node ? default_value :
-    CV_NODE_IS_INT(node.node->tag) ? node.node->data.i :
-    CV_NODE_IS_REAL(node.node->tag) ? cvRound(node.node->data.f) : 0x7fffffff;
+    CV_NODE_IS_INT(node.node->tag) ? node.node->data.i : std::numeric_limits<int>::max();
 }
 
 void read(const FileNode& node, float& value, float default_value)
 {
     value = !node.node ? default_value :
         CV_NODE_IS_INT(node.node->tag) ? (float)node.node->data.i :
-        CV_NODE_IS_REAL(node.node->tag) ? (float)node.node->data.f : 1e30f;
+        CV_NODE_IS_REAL(node.node->tag) ? saturate_cast<float>(node.node->data.f) : std::numeric_limits<float>::max();
 }
 
 void read(const FileNode& node, double& value, double default_value)
 {
     value = !node.node ? default_value :
         CV_NODE_IS_INT(node.node->tag) ? (double)node.node->data.i :
-        CV_NODE_IS_REAL(node.node->tag) ? node.node->data.f : 1e300;
+        CV_NODE_IS_REAL(node.node->tag) ? node.node->data.f : std::numeric_limits<double>::max();
 }
 
 void read(const FileNode& node, String& value, const String& default_value)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/opencv.git



More information about the debian-science-commits mailing list