Fix null pointer reference in length() function.

It's legal for datatype_out to be NULL.