History log of /haiku/src/tests/kits/support/bstring/StringAppendTest.cpp
Revision Date Author Comments
# fbc30e91 31-Dec-2019 Kyle Ambroff-Kao <kyle@ambroffkao.com>

support/String: Revert 6c67c7d63 to fix double-free

6c67c7d63 was attempting to fix a leak caught by a static analysis
tool, but it actually just introduced a double-free bug. Running
`UnitTester BString` will result in a crash.

The original code was correct because, in the event that realloc()
fails in BString::_Resize(), the value of fPrivateData is still
retained. It will be freed by the destructor of BString only if
fPrivateData is not shared by another BString instance, since BStrings
are copy-on-write.

Note that while the change in 6c67c7d63 caused tests to fail, that
doesn't mean those tests are ideal. They only trigger
BString::_Resize() to fail because they depend on implementation
details of hoard2 which limits allocations via malloc() to
1GB. Most malloc() implementations will allow allocations of arbitrary
sizes using anonymous mappings (mmap on Linux, or create_area() in
Haiku). This is a much bigger change, so for now I'm just adding some
comments so that we can revisit these tests if we make a change to the
allocator.

Change-Id: I208c1c7a76b6b4409d237b911c62bb3198e49dab
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2060
Reviewed-by: Stephan Aßmus <superstippi@gmx.de>


# f960e7e9 28-Mar-2018 krish_iyer <krishnaniyer97@gmail.com>

Support kit: Fixed issues in BString unit tests

1: Changed CPPUNIT_ASSERT -> CPPUNIT_ASSERT_EQUAL
2: Fixed coding style: Added two lines after including libraries, maintained 80 characters(MAX) in each line and space at comment start
3: Fixed the failure for "BString::Search" test "i != 0 by chaning the testing method(StartsWith->IStartsWith) and changed the string to be searched(sT->st)

Change-Id: I1237d1f2d0e3af7757963cc940bae929f487f088


# e3872160 17-Nov-2003 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Fixed a warning


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5399 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5480b459 13-Nov-2003 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Another patch from Oliver Tappe: BString behaves better when the user supplies out-of bounds values in Insert(), Remove(), etc.
Code is refactored, and it fully complies with our guidelines.
Tests have been updated too (hint: try the replace tests with R5 and our implementation...)


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5348 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1b0ea0ad 14-Oct-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Added some comments to the tests


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1521 a95241bf-73f2-0310-859d-f6bbb57e9c96


# eee13b4d 03-Oct-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

More tests for BString


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1352 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e38721600a819eabc46a94b0e71c3d6eff87fddc 17-Nov-2003 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Fixed a warning


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5399 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5480b4590e267957b90b79736b3990ddd39459a3 13-Nov-2003 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Another patch from Oliver Tappe: BString behaves better when the user supplies out-of bounds values in Insert(), Remove(), etc.
Code is refactored, and it fully complies with our guidelines.
Tests have been updated too (hint: try the replace tests with R5 and our implementation...)


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5348 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1b0ea0ad6dd4b4a5f08e1d3ec72514976cdf7a60 14-Oct-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Added some comments to the tests


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1521 a95241bf-73f2-0310-859d-f6bbb57e9c96


# eee13b4d9a4bda5ddd1b627845c43a7c905bef19 03-Oct-2002 Stefano Ceccherini <stefano.ceccherini@gmail.com>

More tests for BString


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1352 a95241bf-73f2-0310-859d-f6bbb57e9c96