Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf2a2ad5

Browse files
committed
Fix bug with illegal call to calloc.
1 parentaaf95b6 commitf2a2ad5

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

‎src/bin/psql/print.c

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright 2000 by PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/print.c,v 1.23 2001/10/25 05:49:54 momjian Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/print.c,v 1.24 2001/10/29 06:45:32 ishii Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"print.h"
@@ -251,11 +251,18 @@ print_aligned_text(const char *title, const char *const * headers,
251251
for (ptr=cells;*ptr;ptr++)
252252
cell_count++;
253253

254-
cell_w=calloc(cell_count,sizeof(*cell_w));
255-
if (!cell_w)
254+
if (cell_count>0)
256255
{
257-
perror("calloc");
258-
exit(EXIT_FAILURE);
256+
cell_w=calloc(cell_count,sizeof(*cell_w));
257+
if (!cell_w)
258+
{
259+
perror("calloc");
260+
exit(EXIT_FAILURE);
261+
}
262+
}
263+
else
264+
{
265+
cell_w=0;
259266
}
260267
#endif
261268

@@ -462,11 +469,18 @@ print_aligned_vertical(const char *title, const char *const * headers,
462469
for (ptr=cells;*ptr;ptr++)
463470
cell_count++;
464471

465-
cell_w=calloc(cell_count,sizeof(*cell_w));
466-
if (!cell_w)
472+
if (cell_count>0)
467473
{
468-
perror("calloc");
469-
exit(EXIT_FAILURE);
474+
cell_w=calloc(cell_count,sizeof(*cell_w));
475+
if (!cell_w)
476+
{
477+
perror("calloc");
478+
exit(EXIT_FAILURE);
479+
}
480+
}
481+
else
482+
{
483+
cell_w=0;
470484
}
471485

472486
/* find longest data cell */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp