Date: prev next · Thread: first prev next last
2015 Archives by date, by thread · List index


On 01/17/2015 03:49 PM, julien2412 wrote:
Cppcheck reported this:
     <error file="store/source/stortree.cxx" line="52"
id="arrayIndexOutOfBounds" severity="error" msg="Array
&apos;m_pData[1]&apos; accessed at index 1, which is out of bounds."/>

      41 OStoreBTreeNodeData::OStoreBTreeNodeData (sal_uInt16 nPageSize)
      42     : OStorePageData (nPageSize)
      43 {
      44     base::m_aGuard.m_nMagic = store::htonl(self::theTypeId);
      45     base::m_aDescr.m_nUsed  = store::htons(self::thePageSize); //
usageCount(0)
      46     self::m_aGuard.m_nMagic = store::htonl(0); // depth(0)
      47
      48     sal_uInt16 const n = capacityCount();
      49     T const          t;
      50
      51     for (sal_uInt16 i = 1; i < n; i++)
      52         m_pData[i] = t;

That m_pData is a "flexible array member" whose actual length is controlled dynamically. Cppcheck could probably make use of a heuristic to treat a trailing member declared as an array of length 1 as such a flexible array, as do some other static analysis tools.

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.