avoid-resource-leak-postgres_fdw-connection.patch

application/octet-stream

Filename: avoid-resource-leak-postgres_fdw-connection.patch
Type: application/octet-stream
Part: 0
Message: Avoid resource leak (contrib/postgres_fdw/connection.c)

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: unified
File+
contrib/postgres_fdw/connection.c 5 1
diff --git a/contrib/postgres_fdw/connection.c b/contrib/postgres_fdw/connection.c
index 7e2b822d16..87f3e3727f 100644
--- a/contrib/postgres_fdw/connection.c
+++ b/contrib/postgres_fdw/connection.c
@@ -2355,6 +2355,7 @@ postgres_fdw_connection(PG_FUNCTION_ARGS)
 	ForeignServer *server = GetForeignServer(serverid);
 	UserMapping *user = GetUserMapping(userid, serverid);
 	StringInfoData str;
+	text		*result;
 	const char **keywords;
 	const char **values;
 	char	   *appname;
@@ -2371,12 +2372,15 @@ postgres_fdw_connection(PG_FUNCTION_ARGS)
 		appendEscapedValue(&str, values[i]);
 		sep = " ";
 	}
+	result = cstring_to_text(str.data);
 
 	if (appname != NULL)
 		pfree(appname);
 	pfree(keywords);
 	pfree(values);
-	PG_RETURN_TEXT_P(cstring_to_text(str.data));
+	pfree(str.data);
+
+	PG_RETURN_TEXT_P(result);
 }
 
 /*