[vbox-dev] [External] : Re: Fix for nocrt vector implementation

Andreas Löffler andreas.loeffler at oracle.com
Fri Dec 16 09:08:19 GMT 2022


Hi Martin,

great findings! I also will take care of those.

Thanks again!


-- 
Kind regards / Mit freundlichen Grüßen

******************************************************************
Andreas Löffler | VirtualBox Engineering
Principal Software Engineer | Oracle Virtualization

Oracle Global Services Germany GmbH
Riesstr. 25, D-80992 München
Registergericht: Amtsgericht München, HRB 246209
Geschäftsführer: Ralf Herrmann

Green Oracle <http://www.oracle.com/commitment> 
<http://www.oracle.com/commitment%3e>; Oracle is committed to developing 
practices and products that help protect the environment




On 16.12.22 09:42, Martin Fleisz wrote:
> Hi Andreas,
> 
> thanks! I have found another bug and have attached a fix for it.
> The problem is that if you call end() on an empty vector the current
> implementation tries to de-reference a NULL pointer and crashes.
> 
> I'm submitting this patch under the MIT license.
> 
> Best regards and have a nice weekend,
> 
> Martin Fleisz
> Thincast Technologies GmbH
> 
> 
> diff --git include/iprt/nocrt/vector include/iprt/nocrt/vector
> index 607a75097d3..bbb1acd9de3 100644
> --- include/iprt/nocrt/vector
> +++ include/iprt/nocrt/vector
> @@ -259,17 +259,17 @@ namespace std
>   
>           iterator end() RT_NOEXCEPT
>           {
> -            return iterator(&m_paItems[m_cItems]);
> +            return iterator(m_paItems + m_cItems);
>           }
>   
>           const_iterator end() const RT_NOEXCEPT
>           {
> -            return const_iterator(&m_paItems[m_cItems]);
> +            return const_iterator(m_paItems + m_cItems);
>           }
>   
>           const_iterator cend() const RT_NOEXCEPT
>           {
> -            return const_iterator(&m_paItems[m_cItems]);
> +            return const_iterator(m_paItems + m_cItems);
>           }
>           /** @} */
>   
> 
> 
> On 15.12.2022 14:39, Andreas Löffler wrote:
>> Hello Martin,
>>
>> thanks for reporting this and for the fix! I'll take care of it.
>>
>>
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_0x46BCB4E5EE437BAD.asc
Type: application/pgp-keys
Size: 3143 bytes
Desc: OpenPGP public key
URL: <http://www.virtualbox.org/pipermail/vbox-dev/attachments/20221216/f1206a02/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <http://www.virtualbox.org/pipermail/vbox-dev/attachments/20221216/f1206a02/attachment.sig>


More information about the vbox-dev mailing list