https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=5e435a20b5c851ecc7bea160aaf0b9fa9aec2363
commit 5e435a20b5c851ecc7bea160aaf0b9fa9aec2363 Author: Corinna Vinschen <cori...@vinschen.de> AuthorDate: Thu Feb 27 12:16:45 2025 +0100 Commit: Corinna Vinschen <cori...@vinschen.de> CommitDate: Thu Feb 27 12:16:45 2025 +0100 Cygwin: if_nametoindex: fix a 'use-after-free" uncovered by gcc-14 Fixes: b91d38db37d8 ("Cygwin: net: Make if_nametoindex, etc. consistent with if_nameindex.") Signed-off-by: Corinna Vinschen <cori...@vinschen.de> Diff: --- winsup/cygwin/net.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc index 737e494f8f4a..9d7224a21c43 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -2006,8 +2006,9 @@ cygwin_if_nametoindex (const char *name) for (pap = pa0; pap; pap = pap->Next) if (strcmp (name, pap->AdapterName) == 0) { + unsigned idx = pap->IfIndex; free (pa0); - return pap->IfIndex; + return idx; } if (pa0) free (pa0);