From: Martin Sebor Date: Wed, 26 Jan 2022 00:39:02 +0000 (-0700) Subject: io: Fix use-after-free in ftw [BZ #26779] X-Git-Tag: glibc-2.35~36 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ee52ab25ba875f458981fce22c54e3c04c7a17d3;p=platform%2Fupstream%2Fglibc.git io: Fix use-after-free in ftw [BZ #26779] Reviewed-by: Carlos O'Donell --- diff --git a/io/ftw.c b/io/ftw.c index 2742541..94bd5a9 100644 --- a/io/ftw.c +++ b/io/ftw.c @@ -323,8 +323,9 @@ open_dir_stream (int *dfdp, struct ftw_data *data, struct dir_data *dirp) buf[actsize++] = '\0'; /* Shrink the buffer to what we actually need. */ - data->dirstreams[data->actdir]->content = realloc (buf, actsize); - if (data->dirstreams[data->actdir]->content == NULL) + void *content = realloc (buf, actsize); + data->dirstreams[data->actdir]->content = content; + if (content == NULL) { int save_err = errno; free (buf);