mirror of
https://github.com/postgres/postgres.git
synced 2025-08-19 23:22:23 +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:
@@ -553,6 +553,7 @@ set_pglocale_pgservice(const char *argv0, const char *app)
|
||||
char my_exec_path[MAXPGPATH];
|
||||
char env_path[MAXPGPATH + sizeof("PGSYSCONFDIR=")]; /* longer than
|
||||
* PGLOCALEDIR */
|
||||
char *dup_path;
|
||||
|
||||
/* don't set LC_ALL in the backend */
|
||||
if (strcmp(app, PG_TEXTDOMAIN("postgres")) != 0)
|
||||
@@ -583,7 +584,9 @@ set_pglocale_pgservice(const char *argv0, const char *app)
|
||||
/* set for libpq to use */
|
||||
snprintf(env_path, sizeof(env_path), "PGLOCALEDIR=%s", path);
|
||||
canonicalize_path(env_path + 12);
|
||||
putenv(strdup(env_path));
|
||||
dup_path = strdup(env_path);
|
||||
if (dup_path)
|
||||
putenv(dup_path);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -594,7 +597,9 @@ set_pglocale_pgservice(const char *argv0, const char *app)
|
||||
/* set for libpq to use */
|
||||
snprintf(env_path, sizeof(env_path), "PGSYSCONFDIR=%s", path);
|
||||
canonicalize_path(env_path + 13);
|
||||
putenv(strdup(env_path));
|
||||
dup_path = strdup(env_path);
|
||||
if (dup_path)
|
||||
putenv(dup_path);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user