Fix long standing memory leak bug with free_select_result
authorTatsuo Ishii <ishii@postgresql.org>
Fri, 14 Sep 2012 05:59:55 +0000 (14:59 +0900)
committerTatsuo Ishii <ishii@postgresql.org>
Fri, 14 Sep 2012 05:59:55 +0000 (14:59 +0900)
since pgpool-II 2.3 was born in December 2009.
Actually this bug only appears when operated in replication mode
(triggered by timestamp rewriting process by coincidence).
Per bug track:
http://www.pgpool.net/mantisbt/view.php?id=24

pool_process_query.c

index 1afc52a25b13d5797de25fd29831ef0d42a78a97..ecaf6e9f3f797bb4afe4ff3ba8a03db69a7cb478 100644 (file)
@@ -2372,17 +2372,23 @@ POOL_STATUS OneNode_do_command(POOL_CONNECTION *frontend, POOL_CONNECTION *backe
  */
 void free_select_result(POOL_SELECT_RESULT *result)
 {
-       int i;
+       int i, j;
+       int index;
 
        if (result->nullflags)
                free(result->nullflags);
 
        if (result->data)
        {
+               index = 0;
                for(i=0;i<result->numrows;i++)
                {
-                       if (result->data[i])
-                               free(result->data[i]);
+                       for (j=0;j<result->rowdesc->num_attrs;j++)
+                       {
+                               if (result->data[index])
+                                       free(result->data[index]);
+                               index++;
+                       }
                }
                free(result->data);
        }