From: Jeff Davis Date: Sun, 6 Apr 2025 16:14:42 +0000 (-0700) Subject: Fix unintentional 'NULL' string literal in pg_upgrade. X-Git-Tag: REL_16_9~31 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=57467ec7b3d3769d6e96c3995ca4060ac0167901;p=thirdparty%2Fpostgresql.git 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 Backpatch-through: 16 --- diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c index 846fd65793f..6359109c721 100644 --- a/src/bin/pg_upgrade/pg_upgrade.c +++ b/src/bin/pg_upgrade/pg_upgrade.c @@ -383,7 +383,6 @@ set_locale_and_encoding(void) char *datcollate_literal; char *datctype_literal; char *daticulocale_literal = NULL; - char *daticulocale_src; DbLocaleInfo *locale = old_cluster.template0; prep_status("Setting locale and encoding for new cluster"); @@ -397,10 +396,13 @@ set_locale_and_encoding(void) datctype_literal = PQescapeLiteral(conn_new_template1, locale->db_ctype, strlen(locale->db_ctype)); - daticulocale_src = locale->db_iculocale ? locale->db_iculocale : "NULL"; - daticulocale_literal = PQescapeLiteral(conn_new_template1, - daticulocale_src, - strlen(daticulocale_src)); + + if (locale->db_iculocale) + daticulocale_literal = PQescapeLiteral(conn_new_template1, + locale->db_iculocale, + strlen(locale->db_iculocale)); + else + daticulocale_literal = "NULL"; /* update template0 in new cluster */ if (GET_MAJOR_VERSION(new_cluster.major_version) >= 1500) @@ -430,7 +432,8 @@ set_locale_and_encoding(void) PQfreemem(datcollate_literal); PQfreemem(datctype_literal); - PQfreemem(daticulocale_literal); + if (locale->db_iculocale) + PQfreemem(daticulocale_literal); PQfinish(conn_new_template1);