Fix null pointer reference in length() function.

It's legal for datatype_out to be NULL.
Merge pull request #1141 from kacfengine/length_func_null_ptr_bug

Fix null pointer reference in length() function.