From b1ff98da242db77cda7addb77e935721eec9c064 Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 24 Apr 2025 15:03:15 -0700 Subject: [PATCH] fix: use pgfree for libpq mallocs --- dlg_wingui.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dlg_wingui.c b/dlg_wingui.c index e47f9bdd..700db937 100644 --- a/dlg_wingui.c +++ b/dlg_wingui.c @@ -830,8 +830,10 @@ MYLOG(0, "entering\n"); void *PQconninfoParse(const char *, char **); void PQconninfoFree(void *); +void PQfreemem(void *ptr); typedef void *(*PQCONNINFOPARSEPROC)(const char *, char **); typedef void (*PQCONNINFOFREEPROC)(void *); +typedef void (*PQFREEMEMPROC)(void *); static int ds_options3_update(HWND hdlg, ConnInfo *ci) { @@ -841,6 +843,7 @@ ds_options3_update(HWND hdlg, ConnInfo *ci) HMODULE hmodule; PQCONNINFOPARSEPROC pproc = NULL; PQCONNINFOFREEPROC fproc = NULL; + PQFREEMEMPROC fmproc = NULL; MYLOG(0, "entering got ci=%p\n", ci); @@ -854,8 +857,10 @@ ds_options3_update(HWND hdlg, ConnInfo *ci) const char *logmsg = "libpq parameter error"; MessageBox(hdlg, ermsg ? ermsg : "memory over?", logmsg, MB_ICONEXCLAMATION | MB_OK); - if (NULL != ermsg) - free(ermsg); + if (NULL != ermsg) { + fmproc = (PQFREEMEMPROC)GetProcAddress(hmodule, "PQfreemem"); + (*fmproc)(ermsg); + } FreeLibrary(hmodule); return 1;