bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Uninitialized memory access in `variant<>`


From: Akim Demaille
Subject: Re: Uninitialized memory access in `variant<>`
Date: Sat, 25 Aug 2018 07:47:48 +0200


> Le 24 août 2018 à 19:35, Jiahao Li <address@hidden> a écrit :
> 
> Currently, in bison's C++ parser template (`lalr.cc`), the `variant<>` 
> struct's `build()` method uses placement-new in the form `new (...) T` to 
> initialize a variant type. However, for POD variant types, this will leave 
> the memory space uninitialized. If we subsequently tries to `::move` into a 
> variant object in such state, the call can trigger clang's undefined behavior 
> sanitizer due to accessing the uninitialized memory.
> 
> This attached patch changes the code to use the `new (...) T ()` form (note 
> the parentheses at the end) instead, so that the memory space will be 
> zero-initialized.

Thanks a lot!  Installed.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]