Fixed potentially NULL pointer from malloc.