]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix small memory leak in psql's \bind command
authorMichael Paquier <michael@paquier.xyz>
Wed, 22 Feb 2023 05:22:13 +0000 (14:22 +0900)
committerMichael Paquier <michael@paquier.xyz>
Wed, 22 Feb 2023 05:22:13 +0000 (14:22 +0900)
psql_scan_slash_option() returns a malloc()'d result through a
PQExpBuffer, and exec_command_bind() was doing an extra allocation of
this option for no effect.

Introduced in 5b66de3.

Author: Kyotaro Horiguchi
Reviewed-by: Corey Huinker
Discussion: https://postgr.es/m/20230221.115555.89096938631423206.horikyota.ntt@gmail.com

src/bin/psql/command.c

index b5201edf5551567e8223d3ceb3b93e7780f15ab0..955397ee9dc803f065d9e2089f918f2d75637505 100644 (file)
@@ -480,7 +480,7 @@ exec_command_bind(PsqlScanState scan_state, bool active_branch)
                                nalloc = nalloc ? nalloc * 2 : 1;
                                pset.bind_params = pg_realloc_array(pset.bind_params, char *, nalloc);
                        }
-                       pset.bind_params[nparams - 1] = pg_strdup(opt);
+                       pset.bind_params[nparams - 1] = opt;
                }
 
                pset.bind_nparams = nparams;