Skip to content

Commit 9ac9e9e

Browse files
committed
core: fix String::end() implementation
1 parent 3450528 commit 9ac9e9e

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

modules/core/include/opencv2/core/cvstd.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ const char* String::begin() const
748748
inline
749749
const char* String::end() const
750750
{
751-
return len_ ? cstr_ + 1 : 0;
751+
return len_ ? cstr_ + len_ : NULL;
752752
}
753753

754754
inline

modules/core/test/test_misc.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,10 @@ TEST(Core_String, find_last_of__with__empty_string)
138138
// npos is not exported: EXPECT_EQ(cv::String::npos, p);
139139
EXPECT_EQ(std::string::npos, p);
140140
}
141+
142+
TEST(Core_String, end_method_regression)
143+
{
144+
cv::String old_string = "012345";
145+
cv::String new_string(old_string.begin(), old_string.end());
146+
EXPECT_EQ(6u, new_string.size());
147+
}

0 commit comments

Comments
 (0)