Workaround for the warning in nxt_realloc() on GCC 12.

This closes #639 issue on Github.
This commit is contained in:
Zhidao HONG
2022-02-22 19:18:18 +08:00
parent 170752e96f
commit aeed86c682
2 changed files with 16 additions and 3 deletions

View File

@@ -31,6 +31,12 @@ NGINX Unit updated to 1.27.0.
date="" time="" date="" time=""
packager="Andrei Belov <defan@nginx.com>"> packager="Andrei Belov <defan@nginx.com>">
<change type="feature">
<para>
compatibility with GCC 12.
</para>
</change>
<change type="bugfix"> <change type="bugfix">
<para> <para>
the controller process could crash when a chain with more than 4 the controller process could crash when a chain with more than 4

View File

@@ -64,17 +64,24 @@ nxt_zalloc(size_t size)
void * void *
nxt_realloc(void *p, size_t size) nxt_realloc(void *p, size_t size)
{ {
void *n; void *n;
uintptr_t ptr;
/*
* Workaround for a warning on GCC 12 about using "p" pointer in debug log
* after realloc().
*/
ptr = (uintptr_t) p;
n = realloc(p, size); n = realloc(p, size);
if (nxt_fast_path(n != NULL)) { if (nxt_fast_path(n != NULL)) {
nxt_log_debug(nxt_malloc_log(), "realloc(%p, %uz): %p", p, size, n); nxt_log_debug(nxt_malloc_log(), "realloc(%p, %uz): %p", ptr, size, n);
} else { } else {
nxt_log_alert_moderate(&nxt_malloc_log_moderation, nxt_malloc_log(), nxt_log_alert_moderate(&nxt_malloc_log_moderation, nxt_malloc_log(),
"realloc(%p, %uz) failed %E", "realloc(%p, %uz) failed %E",
p, size, nxt_errno); ptr, size, nxt_errno);
} }
return n; return n;