diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 1999-09-08 16:31:38 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 1999-09-08 16:31:38 +0000 |
commit | b1134e369f8b31a47d0310bf4a1c45a504e90680 (patch) | |
tree | 9064d949ff43075b6347f7c7f40575f3e75f1988 | |
parent | bee7cd2a3664821e80ee0cc18d0b23bc7ea51bf5 (diff) | |
download | postgresql-b1134e369f8b31a47d0310bf4a1c45a504e90680.tar.gz postgresql-b1134e369f8b31a47d0310bf4a1c45a504e90680.zip |
Cope with versions of vsnprintf() written by people who
don't read man pages...
-rw-r--r-- | src/backend/lib/stringinfo.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/backend/lib/stringinfo.c b/src/backend/lib/stringinfo.c index d25a2a00a79..94cb8040604 100644 --- a/src/backend/lib/stringinfo.c +++ b/src/backend/lib/stringinfo.c @@ -8,7 +8,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: stringinfo.c,v 1.21 1999/08/31 01:28:25 tgl Exp $ + * $Id: stringinfo.c,v 1.22 1999/09/08 16:31:38 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -121,7 +121,12 @@ appendStringInfo(StringInfo str, const char *fmt,...) nprinted = vsnprintf(str->data + str->len, avail, fmt, args); va_end(args); - if (nprinted < avail-1) + /* + * Note: some versions of vsnprintf return the number of chars + * actually stored, but at least one returns -1 on failure. + * Be conservative about believing whether the print worked. + */ + if (nprinted >= 0 && nprinted < avail-1) { /* Success. Note nprinted does not include trailing null. */ str->len += nprinted; |