[Kde-pim] [patch] Bug 71549: QGArray::at: Absolute index out of range
Ingo Klöcker
kloecker at kde.org
Sun Feb 11 21:49:27 GMT 2007
On Saturday 10 February 2007 12:23, Martin Koller wrote:
> Hi,
>
> as I got hit already a few times by the mentioned bug, I propose the
> following solution (attached).
> It is a consistency check if the ids file we read has a valid
> content. (The patch does not cure the original problem why the ids
> file has corrupt content. I could not find a way how this can happen
> up till now).
>
> OK to commit ?
array.resize(size);
- for (int i = 0; i < size; i++)
- array.at(i) = 0;
+ memset(array.data(), 0, array.size() * sizeof(KMMsgDictEntry
*)); // faster than a loop
should probably rather be
- array.resize(size);
- for (int i = 0; i < size; i++)
- array.at(i) = 0;
+ array.fill( 0, size );
(see http://doc.trolltech.com/3.3/qmemarray.html#fill)
Moreover, I suggest to use
+ if ( fileSize - pos < (count * sizeof(Q_UINT32)) ) {
instead of
+ if ( fileSize < (count * sizeof(Q_UINT32)) ) {
After all there are only ( fileSize - pos ) bytes left to be read from
the file.
Regards,
Ingo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20070211/21e22cb8/attachment.sig>
-------------- next part --------------
_______________________________________________
kde-pim mailing list
kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/
More information about the kde-pim
mailing list