which could lead to heap based overflows and memory corruption. patch taken from upstream git. ok ajacoutot@