Skip to content

fix: use pgfree for libpq mallocs #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions dlg_wingui.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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);

Expand All @@ -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;
Expand Down