commit cba0363734ed7319728d8219f00bdda543709521 from: Stefan Sperling date: Thu Aug 29 13:01:46 2024 UTC in growwgdata, preserve original pointer during realloc for freeing on error found by codechecker commit - fd571e3ef4998485f4c5e94aa4615138c013dd49 commit + cba0363734ed7319728d8219f00bdda543709521 blob - a2db9c9270a72258e1c86dbc5dd540db5df5139d blob + aa7eec25d1c7260b8c8851d7fd692918333b0e50 --- wg.c +++ wg.c @@ -87,6 +87,7 @@ int growwgdata(size_t by) { ptrdiff_t peer_offset, aip_offset; + struct wg_interface_io *p; if (wg_interface == NULL) wgdata.wgd_size = sizeof(*wg_interface); @@ -95,11 +96,12 @@ growwgdata(size_t by) aip_offset = (void *)wg_aip - (void *)wg_interface; wgdata.wgd_size += by; - wgdata.wgd_interface = realloc(wg_interface, wgdata.wgd_size); - if (wgdata.wgd_interface == NULL) { + p = realloc(wg_interface, wgdata.wgd_size); + if (p == NULL) { printf("%% growwgdata: realloc: %s\n", strerror(errno)); return(-1); } + wgdata.wgd_interface = p; if (wg_interface == NULL) bzero(wgdata.wgd_interface, sizeof(*wg_interface)); wg_interface = wgdata.wgd_interface;