Fix a leak that can occur when len == 0, and as a result we leak a \0 byte.

(From Frantisek Boranek)

OK from miod@