Skip to content

Commit

Permalink
core: forbid conversion real->int in some cases in FileStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
sovrasov committed Jul 12, 2017
1 parent cddf868 commit 5b833db
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions modules/core/src/persistence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5b833db

Please sign in to comment.