diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2016-08-30 18:22:43 -0400 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2016-08-30 18:22:43 -0400 |
| commit | 052cc223d5ce1b727f62afff75797c88d82f880b (patch) | |
| tree | bc60ab35a639f80fd33d8f3391558084d680dbae /src/bin/psql/command.c | |
| parent | 9daec77e165de461fca9d5bc3ece86a91aba5804 (diff) | |
| download | postgresql-052cc223d5ce1b727f62afff75797c88d82f880b.tar.gz | |
Fix a bunch of places that called malloc and friends with no NULL check.
Where possible, use palloc or pg_malloc instead; otherwise, insert
explicit NULL checks.
Generally speaking, these are places where an actual OOM is quite
unlikely, either because they're in client programs that don't
allocate all that much, or they're very early in process startup
so that we'd likely have had a fork() failure instead. Hence,
no back-patch, even though this is nominally a bug fix.
Michael Paquier, with some adjustments by me
Discussion: <CAB7nPqRu07Ot6iht9i9KRfYLpDaF2ZuUv5y_+72uP23ZAGysRg@mail.gmail.com>
Diffstat (limited to 'src/bin/psql/command.c')
| -rw-r--r-- | src/bin/psql/command.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 38038d415f..a9a2fdbf26 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -1182,15 +1182,23 @@ exec_command(const char *cmd, fflush(stdout); } result = gets_fromFile(stdin); + if (!result) + { + psql_error("\\%s: could not read value for variable\n", + cmd); + success = false; + } } - if (!SetVariable(pset.vars, opt, result)) + if (result && + !SetVariable(pset.vars, opt, result)) { psql_error("\\%s: error while setting variable\n", cmd); success = false; } - free(result); + if (result) + free(result); if (prompt_text) free(prompt_text); free(opt); |
