Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Fix breakage of get_ps_display() in the PS_USE_NONE case.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 27 Mar 2022 16:57:46 +0000 (12:57 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 27 Mar 2022 16:57:57 +0000 (12:57 -0400)
Commit 8c6d30f21 caused this function to fail to set *displen
in the PS_USE_NONE code path.  If the variable's previous value
had been negative, that'd lead to a memory clobber at some call
sites.  We'd managed not to notice due to very thin test coverage
of such configurations, but this appears to explain buildfarm member
lorikeet's recent struggles.

Credit to Andrew Dunstan for spotting the problem.  Back-patch
to v13 where the bug was introduced.

Discussion: https://postgr.es/m/136102.1648320427@sss.pgh.pa.us

src/backend/utils/misc/ps_status.c

index 1e8596e664569e3cd1914d7d8a3bbdbdf0f402c3..46d73280d583b4fcc2042ac1c93b1293af333cdd 100644 (file)
@@ -443,6 +443,7 @@ get_ps_display(int *displen)
 
    return ps_buffer + ps_buffer_fixed_size;
 #else
+   *displen = 0;
    return "";
 #endif
 }