Fix calls to 'toArray()' with zero-length array argument