Sounds reasonable. Note that parts of the db code reserved an entry at the
start of every row for something. I have it on my list if things to clean
up.
On Sat, 20 Jun 2015 at 11:15, Michael Meeks <michael.meeks@collabora.com>
wrote:
Hi Noel,
So - another annoying clang plugin request ;-) I just fell over:
https://bugs.documentfoundation.org/show_bug.cgi?id=92194
where by 'fell' I mean several hours of debugging horrible template
mess [ which is inevitably routinely going down the slow paths and we'd
do way better to use pixman IMNSHO ;-]. Anyhow - at the bottom was this:
std::vector< basebmp::Color > aDevPal(2);
- aDevPal.push_back( basebmp::Color( 0, 0, 0 ) );
- aDevPal.push_back( basebmp::Color( 0xff, 0xff, 0xff ) );
+ aDevPal[0] = basebmp::Color( 0, 0, 0 );
+ aDevPal[1] = basebmp::Color( 0xff, 0xff, 0xff );
Basically a mis-understanding of how std::vector works when you
pre-allocate its size - these slots get some (default) contents - in
this case the masks' 1 & 0 state were both default black ;-)
Anyhow - I imagine there are a ton of these around the code-base;
Tor
did some quick greps and quickly found:
mysqlc/source/mysqlc_databasemetadata.cxx:1080
for (sal_uInt32 i = 0; i < 2; i++) {
if (m_rConnection.getMysqlVersion() >= requiredVersion[i]) {
std::vector< Any > aRow(1);
aRow.push_back(makeAny(mysqlc_sdbc_driver::convert(table_types[i],
encoding)));
"and many other similar places in mysqlc"
sax/qa/cppunit/test_converter.cxx:667
std::vector< sal_Int8 > tempSeq(4);
for(sal_Int8 i = 0; i<4; ++i)
tempSeq.push_back(i);
Which also looks highly suspicious =)
And I was wondering ... could there be a clang plugin for that ? in
general I think it's prolly a good swap to discard the use-case of
someone wanting <N> default-initialized items at the front of a vector
and always warn on it ;-)
So I suppose the check would be for a size reservation on a vector
followed by push_back - rather than some array indexing - does that make
sense ? or did I go crazy ;-)
Thanks,
Michael.
--
michael.meeks@collabora.com <><, Pseudo Engineer, itinerant idiot
_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice
Context
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.