[lib/utils] handle zero length