[PATCH 1/2] vi: avoid spurious error if no filename is provided

Laszlo Papp lpapp at kde.org
Mon Aug 18 13:09:31 UTC 2014


Do you know under which circumstances it happens? Is this a regression or
does it require some special environment?

(I cannot reproduce it here with v1.20.2)


On Mon, Aug 18, 2014 at 1:59 PM, Ron Yorston <rmy at tigress.co.uk> wrote:

> Since commit 32afd3a (vi: some simplifications) starting vi without a
> filename on the command line has resulted in an error message in the
> status line:  '(null)' Bad address.
>
> The commit removed a call to the file_size function which checked for a
> null filename.  This prevented file_insert (and hence open) from being
> called with a null filename.
>
> Signed-off-by: Ron Yorston <rmy at tigress.co.uk>
> ---
>  editors/vi.c |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/editors/vi.c b/editors/vi.c
> index 24a9f60..9f55af1 100644
> --- a/editors/vi.c
> +++ b/editors/vi.c
> @@ -722,7 +722,7 @@ int vi_main(int argc, char **argv)
>  /* will also update current_filename */
>  static int init_text_buffer(char *fn)
>  {
> -       int rc;
> +       int rc = -1;
>
>         flush_undo_data();
>         modified_count = 0;
> @@ -741,7 +741,8 @@ static int init_text_buffer(char *fn)
>                 free(current_filename);
>                 current_filename = xstrdup(fn);
>         }
> -       rc = file_insert(fn, text, 1);
> +       if (fn != NULL)
> +               rc = file_insert(fn, text, 1);
>         if (rc < 0) {
>                 // file doesnt exist. Start empty buf with dummy line
>                 char_insert(text, '\n', NO_UNDO);
> --
> 1.7.1
>
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20140818/54ee93ae/attachment.html>


More information about the busybox mailing list