Skip to content

Commit

Permalink
Refs: #38
Browse files Browse the repository at this point in the history
Use stack variable for realloc() return value.
Fixes compilation with GCC 13.2.
  • Loading branch information
ayurchen committed May 2, 2024
1 parent 28f016a commit 235b660
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/glb_wdog.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 235b660

Please sign in to comment.