1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-24 01:29:19 +03:00

Fix memory leaks from incorrect strsep() uses

Commit 5d2e1cc117 introduced some strsep() uses, but it did the
memory management wrong in some cases.  We need to keep a separate
pointer to the allocate memory so that we can free it later, because
strsep() advances the pointer we pass to it, and it at the end it
will be NULL, so any free() calls won't do anything.

(This fixes two of the four places changed in commit 5d2e1cc117.  The
other two don't have this problem.)

Reported-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/79692bf9-17d3-41e6-b9c9-fc8c3944222a@eisentraut.org
This commit is contained in:
Peter Eisentraut
2024-10-18 11:28:54 +02:00
parent 24a36f91e3
commit 4b652692e9
2 changed files with 7 additions and 3 deletions

View File

@@ -120,8 +120,9 @@ pg_logging_init(const char *argv0)
if (colors)
{
char *token;
char *cp = colors;
while ((token = strsep(&colors, ":")))
while ((token = strsep(&cp, ":")))
{
char *e = strchr(token, '=');