Fix bug in del_prepared_list().
authorYoshiyuki Asaba <y-asaba at pgfoundry.org>
Fri, 28 Apr 2006 07:08:01 +0000 (07:08 +0000)
committerYoshiyuki Asaba <y-asaba at pgfoundry.org>
Fri, 28 Apr 2006 07:08:01 +0000 (07:08 +0000)
Pgpool dumped core file when clients sends Close command.

pool_process_query.c

index 30e8ba5383caea6299584c5d28884e46867902cb..54da60f709cd4da6d5d77f6128197d19303615ec 100644 (file)
@@ -3140,13 +3140,12 @@ static void del_prepared_list(PreparedStatementList *p, char *name)
                return;
 
        free(p->stmt_list[i]);
-       if (i == p->cnt - 1)
-               p->cnt--;
-       else
+       if (i != p->cnt - 1)
        {
-               memmove(p->stmt_list[i], p->stmt_list[i+1], sizeof(char *) * (p->cnt - i - 1));
-               p->cnt--;
+               memmove(&p->stmt_list[i], &p->stmt_list[i+1],
+                               sizeof(char *) * (p->cnt - i - 1));
        }
+       p->cnt--;
 }
 
 static void reset_prepared_list(PreparedStatementList *p)