Re: Memory leak when using SQLParamData and SQLPutData
"Inoue, Hiroshi" <[email protected]>
| Newsgroups | gmane.comp.db.postgresql.odbc |
|---|---|
| Message-ID | <[email protected]> |
Hi Mihai, On 2017/12/21 21:55, Mihai Giurgeanu wrote: > Hi Hiroshi, > > Thank you for your reply and let me know if I can do anything to help. Could you try the attached patch? regards, Hiroshi Inoue > > Thank you, > Mihai > > > On Dec 21, 2017 2:50 PM, "Inoue, Hiroshi" <[email protected] > <mailto:[email protected]>> wrote: > > Hi Mihai, > > > On 2017/12/21 17:26, Mihai Giurgeanu wrote: > > Hi, > > When executing a prepared insert statement and using > SQL_DATA_AT_EXEC parameters that will be sent with > SQLParamData and SQLPutData, the driver will leak memory for > parameters. The memory will not be deallocated not even the > handles are freed and the program disconnects from the database. > > I am attaching a small project to demonstrate the bug. You can > also browse the project at > https://hub.darcs.net/mihaigiurgeanu/psqlodbc-insert-leak > <https://hub.darcs.net/mihaigiurgeanu/psqlodbc-insert-leak> > > > Thanks for the report. > It would take some time to examine the issue because I am very > busy now, > > regards, > Hiroshi Inoue >
data_at_exec.patch
(text/plain, 503 B)
diff --git a/execute.c b/execute.c index 24b063a..95dd814 100644 --- a/execute.c +++ b/execute.c @@ -970,6 +970,12 @@ next_param_row: if (ipdopts->param_status_ptr) ipdopts->param_status_ptr[stmt->exec_current_row] = SQL_PARAM_ERROR; + /* + * Free any data at exec params before the statement is executed + * again. + */ + SC_free_params(stmt, STMT_FREE_PARAMS_DATA_AT_EXEC_ONLY); + /* * Check if statement has any data-at-execute parameters when it is * not in SC_pre_execute.