Most glGet* functions don't change change the contents of the buffer
if an error is generated. Buffers created with alloca have undefined
contents, which if used causes undefined behaviour (eg: allocating a
huge chunk of memory if a size is peeked, overwriting unspecified
memory if a pointer is peeked).
This patch mitigates the issue to some extent by using with 0 and
with nullPtr instead of alloca, so at least the content of the
buffer is defined. There are still some places unchanged, this patch
concentrates on cases where the result would be used as a size for
memory allocations or as a pointer.
Most glGet* functions don't change change the contents of the buffer if an error is generated. Buffers created with
alloca
have undefined contents, which if used causes undefined behaviour (eg: allocating a huge chunk of memory if a size is peeked, overwriting unspecified memory if a pointer is peeked).This patch mitigates the issue to some extent by using
with 0
andwith nullPtr
instead ofalloca
, so at least the content of the buffer is defined. There are still some places unchanged, this patch concentrates on cases where the result would be used as a size for memory allocations or as a pointer.The initial bug report was here: https://www.haskell.org/pipermail/hopengl/2015-January/001152.html