On Mon, Jan 15, 2024 at 11:32 AM Sasmit Utkarsh <utkarshsas...@gmail.com> wrote:
> Hi Team, > > I am trying to test a code which basically tries to read some data from > postgresql db in a loop through a function SQL_get_tpf_rw() whose > definition and other details are shared in the attached file along with the > memory leak report resulted during testing. Could you let me know if i > missed calling anywhere PQclear() > in SQL_get_tpf_rw() which resulted in the below . > > Last few lines from the report > > yep: for example, if (PQresultStatus(*res*) != PGRES_TUPLES_OK) { LOG_ERROR("SELECT failed: %s", PQerrorMessage(conn)); LOG_DEBUG("ROLLBACK TRANSACTION AND CHAIN"); *res* = PQexec(conn,"ROLLBACK TRANSACTION AND CHAIN"); LOG_ERROR("INVALID_FILE_ADDRESS %08X",fa); rc = ERR_INVALID_FILE_ADDRESS; See highlighted bits. You're reusing the res object before clearing it. there may be other cases, but this jumped off the page. merlin