BUG #15541: Use after release in PQprint - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #15541: Use after release in PQprint
Date
Msg-id 15541-c835d8b9a903f7ad@postgresql.org
Whole thread Raw
Responses Re: BUG #15541: Use after release in PQprint
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      15541
Logged by:          Pan Bian
Email address:      bianpan2016@163.com
PostgreSQL version: 11.1
Operating system:   Linux
Description:

File: src/interfaces/libpq/fe-print.c
Function: PQprint
Issue details:

The function PQprint releases the file hander fout via pclose or _pclose
when usePipe is true. After that, fout is used again to write message
"fputs("</table>\n", fout);".

For your convenience, I copy-and-paste related code as follows.

 67 void
 68 PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
 69 {
               ...
310         if (usePipe)
311         {
312 #ifdef WIN32
313             _pclose(fout);
314 #else
315             pclose(fout);
316 
317 #ifdef ENABLE_THREAD_SAFETY
318             /* we can't easily verify if EPIPE occurred, so say it did
*/
319             if (sigpipe_masked)
320                 pq_reset_sigpipe(&osigset, sigpipe_pending, true);
321 #else
322             pqsignal(SIGPIPE, oldsigpipehandler);
323 #endif                          /* ENABLE_THREAD_SAFETY */
324 #endif                          /* WIN32 */
325         }
326         if (po->html3 && !po->expanded)
327             fputs("</table>\n", fout);
328     }
329 }

Thank you,
Pan Bian


pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #15540: Use after release in ExecuteTruncateGuts
Next
From: Jim Finnerty
Date:
Subject: Re: BUG #15538: Postgres query performance is slow.