Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: ZSH crashed when reading bytes from a large binary
> 2022/09/11 23:43, Liu, Song <songliu@xxxxxxx> wrote:
>
> The problem is that, when ZSH failed to reallocate memory, ZSH didn’t check the return value of `realloc` function and handle the error. This will make ZSH crash.
>
> On line 6923 of `zsh/Src/builtin.c`, the correct code should like the following:
>
> ``` c
> If (buf = realloc(buf, bsiz *= 2)) {
> // same as previous code
> } else {
> free(buf);
> return EXIT_FAILURE;
> }
There are many other places where the return value of realloc() is not checked.
Can we simply replace them by zrealloc()?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author