fix segfault on gcc-4.2/4.6