mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
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>
This commit is contained in:
@ -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);
|
||||
|
Reference in New Issue
Block a user