Commit f2a2ad59 authored by Tatsuo Ishii's avatar Tatsuo Ishii

Fix bug with illegal call to calloc.

parent aaf95b6c
......@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/bin/psql/print.c,v 1.23 2001/10/25 05:49:54 momjian Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/print.c,v 1.24 2001/10/29 06:45:32 ishii Exp $
*/
#include "postgres_fe.h"
#include "print.h"
......@@ -251,12 +251,19 @@ print_aligned_text(const char *title, const char *const * headers,
for (ptr = cells; *ptr; ptr++)
cell_count++;
if (cell_count > 0)
{
cell_w = calloc(cell_count, sizeof(*cell_w));
if (!cell_w)
{
perror("calloc");
exit(EXIT_FAILURE);
}
}
else
{
cell_w = 0;
}
#endif
......@@ -462,12 +469,19 @@ print_aligned_vertical(const char *title, const char *const * headers,
for (ptr = cells; *ptr; ptr++)
cell_count++;
if (cell_count > 0)
{
cell_w = calloc(cell_count, sizeof(*cell_w));
if (!cell_w)
{
perror("calloc");
exit(EXIT_FAILURE);
}
}
else
{
cell_w = 0;
}
/* find longest data cell */
for (i = 0, ptr = cells; *ptr; ptr++, i++)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment