Free any data at exec params before the statement is executed again or the next set...
authorHiroshi Inoue <h-inoue@dream.email.ne.jp>
Sat, 23 Dec 2017 23:36:00 +0000 (08:36 +0900)
committerHiroshi Inoue <h-inoue@dream.email.ne.jp>
Sat, 23 Dec 2017 23:36:01 +0000 (08:36 +0900)
Per report from Mihai Giurgeanu <mihai.giurgeanu@gmail.com>.

execute.c
statement.c

index 24b063a021b91d5bbcefb973950c8e2ecde28065..ce2d27bed85df7f4f55f4b35324b7f9cc22f80da 100644 (file)
--- a/execute.c
+++ b/execute.c
@@ -970,6 +970,14 @@ 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 or the next set of parameters is processed.
+    *  If not, then there will be a memory leak when the next
+    *  SQLParamData/SQLPutData is called.
+    */
+   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.
@@ -1162,10 +1170,9 @@ PGAPI_Cancel(HSTMT hstmt)        /* Statement to cancel. */
    {
        /* Waiting for more data from SQLParamData/SQLPutData. Cancel that. */
        /*
-        * Note, any previous data-at-exec buffers will be freed in the
-        * recycle
+        * Note, any previous data-at-exec buffers will be freed
+        * if they call SQLExecDirect or SQLExecute again.
         */
-       /* if they call SQLExecDirect or SQLExecute again. */
 
        ENTER_STMT_CS(stmt);
        SC_clear_error(stmt);
index a521592d2ac2fe055dcc6b05c019962886ed4c31..5372e048c6122f0c89d2f51dc57f524f96119662 100644 (file)
@@ -874,11 +874,6 @@ MYLOG(1, "statement=%p ommitted=0\n", self);
 
    self->lobj_fd = -1;
 
-   /*
-    * Free any data at exec params before the statement is executed
-    * again.  If not, then there will be a memory leak when the next
-    * SQLParamData/SQLPutData is called.
-    */
    SC_free_params(self, STMT_FREE_PARAMS_DATA_AT_EXEC_ONLY);
    SC_initialize_stmts(self, FALSE);
    cancelNeedDataState(self);