libmal: Handle empty documents in search (fixes #66)