From 4692d4b36e5aed35a8d52f4ffc66b06c2a456e6d Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Thu, 4 Jul 2013 17:06:00 +0400 Subject: [PATCH 1/2] Fix bug: cv::String would break if assigned to itself. --- modules/core/include/opencv2/core/cvstd.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/core/include/opencv2/core/cvstd.hpp b/modules/core/include/opencv2/core/cvstd.hpp index 0232c6d08477..0f96941df1e0 100644 --- a/modules/core/include/opencv2/core/cvstd.hpp +++ b/modules/core/include/opencv2/core/cvstd.hpp @@ -580,6 +580,8 @@ String::~String() inline String& String::operator=(const String& str) { + if (&str == this) return *this; + deallocate(); if (str.cstr_) CV_XADD(((int*)str.cstr_)-1, 1); cstr_ = str.cstr_; From 0daf4b800a5420ca701ba71554b98a96036be5f1 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Thu, 4 Jul 2013 17:09:29 +0400 Subject: [PATCH 2/2] Fix bug: CommandLineParserParams's comparator would fail with equal arguments. --- modules/core/src/command_line_parser.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/modules/core/src/command_line_parser.cpp b/modules/core/src/command_line_parser.cpp index 4f4c8db4aa59..b082faee62fb 100644 --- a/modules/core/src/command_line_parser.cpp +++ b/modules/core/src/command_line_parser.cpp @@ -136,18 +136,13 @@ void CommandLineParser::getByIndex(int index, bool space_delete, int type, void* static bool cmp_params(const CommandLineParserParams & p1, const CommandLineParserParams & p2) { + if (p1.number < p2.number) + return true; + if (p1.number > p2.number) return false; - if (p1.number == -1 && p2.number == -1) - { - if (p1.keys[0].compare(p2.keys[0]) > 0) - { - return false; - } - } - - return true; + return p1.keys[0].compare(p2.keys[0]) < 0; } CommandLineParser::CommandLineParser(int argc, const char* const argv[], const String& keys)