Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 297e7f3

Browse files
committed
Fix \h to not go past array bounds
1 parent 11ae8ba commit 297e7f3

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/bin/psql/help.c

Lines changed: 8 additions & 7 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/help.c,v 1.25 2000/04/12 17:16:22 momjian Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/help.c,v 1.26 2000/04/24 22:41:43 momjian Exp $
77
*/
88
#include "postgres.h"
99
#include "help.h"
@@ -265,13 +265,14 @@ helpSQL(const char *topic)
265265

266266
for (i = 0; i < items_per_column; i++)
267267
{
268-
printf(" %-25s%-25s%-25s\n",
269-
VALUE_OR_NULL(QL_HELP[i].cmd),
270-
VALUE_OR_NULL(QL_HELP[i + items_per_column].cmd),
271-
VALUE_OR_NULL(QL_HELP[i + 2 * items_per_column].cmd)
272-
);
268+
printf(" %-25s%-25s",
269+
VALUE_OR_NULL(QL_HELP[i].cmd),
270+
VALUE_OR_NULL(QL_HELP[i + items_per_column].cmd));
271+
if (i + 2 * items_per_column < QL_HELP_COUNT)
272+
printf("%-25s",
273+
VALUE_OR_NULL(QL_HELP[i + 2 * items_per_column].cmd));
274+
fputc('\n', stdout);
273275
}
274-
putc('\n', stdout);
275276
}
276277

277278
else

0 commit comments

Comments
 (0)