diff options
author | Jeff Davis | 2025-04-06 16:13:43 +0000 |
---|---|---|
committer | Jeff Davis | 2025-04-06 16:13:43 +0000 |
commit | 0851b6573877f0d22510688623eff4a2ab1dea49 (patch) | |
tree | 11ba79b3b50b3a6518d4fe36dca56762a77fbac1 /src | |
parent | 5e7be43f4b8bfe77570e566b89f23fc73ea625dc (diff) |
Fix unintentional 'NULL' string literal in pg_upgrade.
Introduced in 2a083ab807.
Note: backport of commit 945126234b, which was missed at the time.
Discussion: https://postgr.es/m/e852442da35b4f31acc600ed98bbee0f12e65e0c.camel@j-davis.com
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Backpatch-through: 16
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/pg_upgrade/pg_upgrade.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c index 4fcd4bac153..bb5a223e1c6 100644 --- a/src/bin/pg_upgrade/pg_upgrade.c +++ b/src/bin/pg_upgrade/pg_upgrade.c @@ -408,7 +408,6 @@ set_locale_and_encoding(void) char *datcollate_literal; char *datctype_literal; char *datlocale_literal = NULL; - char *datlocale_src; DbLocaleInfo *locale = old_cluster.template0; prep_status("Setting locale and encoding for new cluster"); @@ -422,10 +421,13 @@ set_locale_and_encoding(void) datctype_literal = PQescapeLiteral(conn_new_template1, locale->db_ctype, strlen(locale->db_ctype)); - datlocale_src = locale->db_locale ? locale->db_locale : "NULL"; - datlocale_literal = PQescapeLiteral(conn_new_template1, - datlocale_src, - strlen(datlocale_src)); + + if (locale->db_locale) + datlocale_literal = PQescapeLiteral(conn_new_template1, + locale->db_locale, + strlen(locale->db_locale)); + else + datlocale_literal = "NULL"; /* update template0 in new cluster */ if (GET_MAJOR_VERSION(new_cluster.major_version) >= 1700) @@ -469,7 +471,8 @@ set_locale_and_encoding(void) PQfreemem(datcollate_literal); PQfreemem(datctype_literal); - PQfreemem(datlocale_literal); + if (locale->db_locale) + PQfreemem(datlocale_literal); PQfinish(conn_new_template1); |