bug-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Texinfo 7.0.93 pretest available


From: Gavin Smith
Subject: Re: Texinfo 7.0.93 pretest available
Date: Sun, 8 Oct 2023 12:50:51 +0100

On Sun, Oct 08, 2023 at 02:39:36PM +0300, Eli Zaretskii wrote:
> Sorry, I was mistaken: the Gnulib getdelim is not used here.  Instead,
> this build uses the MinGW implementation of getdelim, and that one has
> a subtle bug, which rears its ugly head because the second argument to
> getline, here:
> 
>           status = getline (&line, &n, input_file);
> 
> is not initialized to any value.  The simple fix below avoids the
> crash and allows the build to run to completion:

(I'd noticed that and checked the Gnulib implementation didn't need n
to be defined if the first argument was null.)

According to the documentation for getline,

     If you set ‘*LINEPTR’ to a null pointer, and ‘*N’ to zero, before
     the call, then ‘getline’ allocates the initial buffer for you by
     calling ‘malloc’.  This buffer remains allocated even if ‘getline’
     encounters errors and is unable to read any bytes.

Hence, I propose to initialise n to 0, rather than 120 as in the patch
below.

> 
> --- tp/Texinfo/XS/parsetexi/input.c~  2023-08-14 23:12:04.000000000 +0300
> +++ tp/Texinfo/XS/parsetexi/input.c   2023-10-08 14:35:33.142000000 +0300
> @@ -395,7 +395,7 @@ next_text (ELEMENT *current)
>  {
>    ssize_t status;
>    char *line = 0;
> -  size_t n;
> +  size_t n = 120;
>    FILE *input_file;
>  
>    if (input_pushback_string)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]