fix segfault in length() from empty array