On Sun, 24 Oct 2021 20:45:47 -0400, Dave Voutila wrote:

> We end up freeing some strings and unlinking the temp file. You can
> easily see this without a debugger by checking /tmp before and after the
> reproduction step of an arg-less ':e'.

I debugged this yesterday as well and came to the same conclusion.
Treating this as a no-op should be fine, however you also need to
free ep before returning.

 - todd

> diff 8095b13035d3c80c255344b9166e7f4ff88e61e3 /usr/src
> blob - 0b6ae026533e5696a31f4bd87291ccd1d7d5e58f
> file + usr.bin/vi/common/exf.c
> --- usr.bin/vi/common/exf.c
> +++ usr.bin/vi/common/exf.c
> @@ -170,12 +170,20 @@ file_init(SCR *sp, FREF *frp, char *rcv_name, int flag
>        * If no name or backing file, for whatever reason, create a backing
>        * temporary file, saving the temp file name so we can later unlink
>        * it.  If the user never named this file, copy the temporary file name
>        * to the real name (we display that until the user renames it).
>        */
>       oname = frp->name;
> +
> +     /*
> +      * User is editing a name file that doesn't exist yet other than as a
> +      * temporary file.
> +      */
> +     if (!exists && oname != NULL && frp->tname != NULL)
> +             return (1);
> +
>       if (LF_ISSET(FS_OPENERR) || oname == NULL || !exists) {
>               /*
>                * Don't try to create a temporary support file twice.
>                */
>               if (frp->tname != NULL)
>                       goto err;
>

Reply via email to