Review Request 128893: Fix sorted insert (aka flat_map like insert).
Christoph Cullmann
cullmann at kde.org
Sun Sep 11 20:26:42 UTC 2016
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/128893/
-----------------------------------------------------------
Review request for KDE Frameworks and Boudhayan Gupta.
Repository: baloo
Description
-------
Old code was plain wrong:
- auto it = std::upper_bound(subDocs.begin(), subDocs.end(), id);
-
- // Merge the id if it does not
- auto prev = it - 1;
- if (*prev != id) {
- subDocs.insert(it, id);
- }
=> you deref begin()-1 in my test case
=> BAM ;)
Diffs
-----
autotests/unit/engine/documenturldbtest.cpp 448821b
src/engine/documenturldb.cpp 5083e7a
src/engine/idutils.h cc7da9c
src/engine/writetransaction.cpp 3808970
Diff: https://git.reviewboard.kde.org/r/128893/diff/
Testing
-------
Wrote test, valgrind shows error (or you get segfault, depending on luck) with old code, new one works.
Thanks,
Christoph Cullmann
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20160911/ee65f14a/attachment.html>
More information about the Kde-frameworks-devel
mailing list