Skip to content

Commit 505ae7b

Browse files
authored
fix: use pgfree for libpq mallocs (#114)
1 parent cc5d02a commit 505ae7b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

dlg_wingui.c

+7-2
Original file line numberDiff line numberDiff line change
@@ -830,8 +830,10 @@ MYLOG(0, "entering\n");
830830

831831
void *PQconninfoParse(const char *, char **);
832832
void PQconninfoFree(void *);
833+
void PQfreemem(void *ptr);
833834
typedef void *(*PQCONNINFOPARSEPROC)(const char *, char **);
834835
typedef void (*PQCONNINFOFREEPROC)(void *);
836+
typedef void (*PQFREEMEMPROC)(void *);
835837
static int
836838
ds_options3_update(HWND hdlg, ConnInfo *ci)
837839
{
@@ -841,6 +843,7 @@ ds_options3_update(HWND hdlg, ConnInfo *ci)
841843
HMODULE hmodule;
842844
PQCONNINFOPARSEPROC pproc = NULL;
843845
PQCONNINFOFREEPROC fproc = NULL;
846+
PQFREEMEMPROC fmproc = NULL;
844847

845848
MYLOG(0, "entering got ci=%p\n", ci);
846849

@@ -854,8 +857,10 @@ ds_options3_update(HWND hdlg, ConnInfo *ci)
854857
const char *logmsg = "libpq parameter error";
855858

856859
MessageBox(hdlg, ermsg ? ermsg : "memory over?", logmsg, MB_ICONEXCLAMATION | MB_OK);
857-
if (NULL != ermsg)
858-
free(ermsg);
860+
if (NULL != ermsg) {
861+
fmproc = (PQFREEMEMPROC)GetProcAddress(hmodule, "PQfreemem");
862+
(*fmproc)(ermsg);
863+
}
859864
FreeLibrary(hmodule);
860865

861866
return 1;

0 commit comments

Comments
 (0)