fix leaking file handle

Also updated zdir and zfile to check for truthness first
@xaqq according to the comment at the top of the function the filename
shall be stored even when a error occurs?
Wouldn’t a free(filename_copy) also nullify self->filename?