diff options
-rw-r--r-- | chart2/source/controller/main/DrawCommandDispatch.cxx | 2 | ||||
-rw-r--r-- | sal/qa/rtl/oustring/rtl_OUString2.cxx | 9 | ||||
-rw-r--r-- | sal/qa/rtl/oustring/rtl_ustr.cxx | 10 | ||||
-rw-r--r-- | sal/rtl/strtmpl.hxx | 1 |
4 files changed, 9 insertions, 13 deletions
diff --git a/chart2/source/controller/main/DrawCommandDispatch.cxx b/chart2/source/controller/main/DrawCommandDispatch.cxx index a20d2ba1a7fb..afc3b907828d 100644 --- a/chart2/source/controller/main/DrawCommandDispatch.cxx +++ b/chart2/source/controller/main/DrawCommandDispatch.cxx @@ -533,7 +533,7 @@ bool DrawCommandDispatch::parseCommandURL( const OUString& rCommandURL, sal_uInt OUString aBaseCommand; OUString aType; - sal_Int32 nIndex = 1; + sal_Int32 nIndex = std::min(sal_Int32(1), rCommandURL.getLength()); OUString aToken = rCommandURL.getToken( 0, '.', nIndex ); if ( nIndex == -1 || aToken.isEmpty() ) { diff --git a/sal/qa/rtl/oustring/rtl_OUString2.cxx b/sal/qa/rtl/oustring/rtl_OUString2.cxx index 5f68629a4c09..22e731fd16f1 100644 --- a/sal/qa/rtl/oustring/rtl_OUString2.cxx +++ b/sal/qa/rtl/oustring/rtl_OUString2.cxx @@ -794,14 +794,6 @@ public: // should not GPF with negative index } - void getToken_007() - { - OUString suTokenStr("a;b"); - sal_Int32 n = 5; // greater than string length - CPPUNIT_ASSERT_EQUAL(OUString(), suTokenStr.getToken(0, ';', n)); - CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), n); - } - CPPUNIT_TEST_SUITE(getToken); CPPUNIT_TEST(getToken_000); CPPUNIT_TEST(getToken_001); @@ -810,7 +802,6 @@ public: CPPUNIT_TEST(getToken_004); CPPUNIT_TEST(getToken_005); CPPUNIT_TEST(getToken_006); - CPPUNIT_TEST(getToken_007); CPPUNIT_TEST_SUITE_END(); }; // class getToken diff --git a/sal/qa/rtl/oustring/rtl_ustr.cxx b/sal/qa/rtl/oustring/rtl_ustr.cxx index 873d771f9457..f5c405dfd948 100644 --- a/sal/qa/rtl/oustring/rtl_ustr.cxx +++ b/sal/qa/rtl/oustring/rtl_ustr.cxx @@ -1031,9 +1031,13 @@ namespace rtl_ustr class getToken : public CppUnit::TestFixture { void getToken_000() - { - // TODO - } + { + OUString s("a;b;c"); + // Replace the string in place + const sal_Int32 i = rtl_uString_getToken(&s.pData, s.pData, 1, ';', 0); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), i); + CPPUNIT_ASSERT_EQUAL(OUString("b"), s); + } CPPUNIT_TEST_SUITE(getToken); CPPUNIT_TEST(getToken_000); diff --git a/sal/rtl/strtmpl.hxx b/sal/rtl/strtmpl.hxx index 0f0cc6755eb3..07ea6d6cbba8 100644 --- a/sal/rtl/strtmpl.hxx +++ b/sal/rtl/strtmpl.hxx @@ -1256,6 +1256,7 @@ sal_Int32 getToken ( IMPL_RTL_STRINGDATA** ppThis { assert(ppThis); assert(pStr); + assert(nIndex <= pStr->length); // Set ppThis to an empty string and return -1 if either nToken or nIndex is // negative: |