Fixes for a motley collection of NULL pointer dereference, out-of-bounds accesses, heap overflow, etc.