diff options
author | Tatsuo Ishii <ishii@postgresql.org> | 2001-10-29 06:45:32 +0000 |
---|---|---|
committer | Tatsuo Ishii <ishii@postgresql.org> | 2001-10-29 06:45:32 +0000 |
commit | f2a2ad59bc5673cd93548c66db82222f868c14b7 (patch) | |
tree | 00b45b4b00472d1446ee897008682af23a7d7203 /src | |
parent | aaf95b6c8639c47049d9d499bbd30c5bc250d7e5 (diff) |
Fix bug with illegal call to calloc.
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/psql/print.c | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/src/bin/psql/print.c b/src/bin/psql/print.c index 97ca96d6601..010da3678e6 100644 --- a/src/bin/psql/print.c +++ b/src/bin/psql/print.c @@ -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,11 +251,18 @@ print_aligned_text(const char *title, const char *const * headers, for (ptr = cells; *ptr; ptr++) cell_count++; - cell_w = calloc(cell_count, sizeof(*cell_w)); - if (!cell_w) + if (cell_count > 0) { - perror("calloc"); - exit(EXIT_FAILURE); + cell_w = calloc(cell_count, sizeof(*cell_w)); + if (!cell_w) + { + perror("calloc"); + exit(EXIT_FAILURE); + } + } + else + { + cell_w = 0; } #endif @@ -462,11 +469,18 @@ print_aligned_vertical(const char *title, const char *const * headers, for (ptr = cells; *ptr; ptr++) cell_count++; - cell_w = calloc(cell_count, sizeof(*cell_w)); - if (!cell_w) + if (cell_count > 0) { - perror("calloc"); - exit(EXIT_FAILURE); + cell_w = calloc(cell_count, sizeof(*cell_w)); + if (!cell_w) + { + perror("calloc"); + exit(EXIT_FAILURE); + } + } + else + { + cell_w = 0; } /* find longest data cell */ |