From 9ac9e9e29ad6bc0393986040ae702a24af9e8f50 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 9 Feb 2017 13:23:35 +0300 Subject: [PATCH] core: fix String::end() implementation --- modules/core/include/opencv2/core/cvstd.hpp | 2 +- modules/core/test/test_misc.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/core/include/opencv2/core/cvstd.hpp b/modules/core/include/opencv2/core/cvstd.hpp index 2d40bd069f..28dae3db5f 100644 --- a/modules/core/include/opencv2/core/cvstd.hpp +++ b/modules/core/include/opencv2/core/cvstd.hpp @@ -748,7 +748,7 @@ const char* String::begin() const inline const char* String::end() const { - return len_ ? cstr_ + 1 : 0; + return len_ ? cstr_ + len_ : NULL; } inline diff --git a/modules/core/test/test_misc.cpp b/modules/core/test/test_misc.cpp index 9e69ffb664..e018d74a15 100644 --- a/modules/core/test/test_misc.cpp +++ b/modules/core/test/test_misc.cpp @@ -138,3 +138,10 @@ TEST(Core_String, find_last_of__with__empty_string) // npos is not exported: EXPECT_EQ(cv::String::npos, p); EXPECT_EQ(std::string::npos, p); } + +TEST(Core_String, end_method_regression) +{ + cv::String old_string = "012345"; + cv::String new_string(old_string.begin(), old_string.end()); + EXPECT_EQ(6u, new_string.size()); +}