fix possible segfaults with null arrays (#5)