This is mostly to suppress compiler warnings, although in principle
the cases could result in undesirable behavior.
Martin Pitt
*
* Copyright (c) 2000-2010, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/prompt.c,v 1.53 2010/01/02 16:57:59 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/prompt.c,v 1.54 2010/04/30 17:09:13 tgl Exp $
*/
#include "postgres_fe.h"
fd = popen(file, "r");
if (fd)
{
- fgets(buf, sizeof(buf), fd);
+ if (fgets(buf, sizeof(buf), fd) == NULL)
+ buf[0] = '\0';
pclose(fd);
}
if (strlen(buf) > 0 && buf[strlen(buf) - 1] == '\n')
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.391 2010/03/17 20:58:38 petere Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.392 2010/04/30 17:09:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
*ret;
int len;
- fgets(buf, sizeof(buf), fp);
+ if (fgets(buf, sizeof(buf), fp) == NULL)
+ break;
len = strlen(buf);
if (len == 0)