plasma-umass / Mesh

A memory allocator that automatically reduces the memory footprint of C/C++ applications.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dereferencing partially uninitialized memory as a random number

Corillian opened this issue · comments

It appears that every second iteration of MWC64::next() you are returning the value of _index, which will always be 1, along with 4 bytes of potentially uninitialized memory - which I suppose does introduce some amount of randomness :p. This is because (&_value + 1) == ((uint64_t*)&_index) except that _index is an int.

auto v = ((uint64_t *)&_value)[_index];

@Corillian eep! amazing find, sorry it took so long to get back to you. This was indeed a pretty glaring bug, which should be fixed now.

Thanks again!