From 235b660cf45d8f91eeaff4171a157b38c445af58 Mon Sep 17 00:00:00 2001 From: Alexey Yurchenko Date: Thu, 2 May 2024 21:44:38 +0300 Subject: [PATCH] Refs: codership/glb#38 Use stack variable for realloc() return value. Fixes compilation with GCC 13.2. --- src/glb_wdog.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/glb_wdog.c b/src/glb_wdog.c index 43f72d3..0bb8730 100644 --- a/src/glb_wdog.c +++ b/src/glb_wdog.c @@ -329,8 +329,8 @@ wdog_copy_result (wdog_dst_t* const d, double* const max_lat, int const lf) if (others_len < res->others_len || others_len > (res->others_len * 2)) { // buffer size is too different, reallocate - d->result.others = realloc (others, res->others_len); - if (!d->result.others && res->others_len > 0) { + void* const tmp = realloc (others, res->others_len); + if (!tmp && res->others_len > 0) { // this is pretty much fatal, but we'll try free (others); d->result.others_len = 0; @@ -339,6 +339,7 @@ wdog_copy_result (wdog_dst_t* const d, double* const max_lat, int const lf) changed_length = true; d->result.others_len = res->others_len; } + d->result.others = tmp; } assert (d->result.others || 0 == d->result.others_len);