Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w2H2b-000985-06 for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Mar 2026 23:08:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w2H2Z-00E20R-2Q for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Mar 2026 23:08:03 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w2H2Z-00E20J-1U for pgsql-hackers@lists.postgresql.org; Mon, 16 Mar 2026 23:08:03 +0000 Received: from mail-oo1-xc33.google.com ([2607:f8b0:4864:20::c33]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w2H2V-000000005dd-2gGW for pgsql-hackers@postgresql.org; Mon, 16 Mar 2026 23:08:02 +0000 Received: by mail-oo1-xc33.google.com with SMTP id 006d021491bc7-662efd1bdd4so133999eaf.0 for ; Mon, 16 Mar 2026 16:08:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1773702480; cv=none; d=google.com; s=arc-20240605; b=Y07ey8Fi8E7pZPMwoY26TXQ/ULCAtcLUq3Ovzi3G7qmtoL+dqzCOmEFgndTAIQ3vQX vRJTut+iS+kr2TBpyrDdcwJdyF2pO83v4UDR8q3UzlL9UXrkie1Uvox29ihQkDJ5rSgl rFlyYfEZkViJ3XLZqiKfY7jhH34OQUR869SaFbhw6t+JS399roTsZHXj1mN7prGpjw8f GByIpEki+J24VcBVFk9P/obSBRe2dL+UNmrgQRdVuZVHovv8nvgqTj3sGUvADxSAanjU r6rI02TJqsRu2KuDvMEw+mgKNtBSQJmvhbxpV8myxEm/iU9gnNoDrf2BYe0Ue8w6sd0i nx8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=jmaW4N+iY5KZojwx/299tjmKP3mLAmVNt7J+bx0Cwn4=; fh=TVfGSc1ROJnfT2DI0+LhstR3EAj4703kqaeMLTgraqk=; b=I14oZIV9rPfVTQ7cqgSMkuX6xnhFKXywb96Zchjxkdl5Ipe3K46QI+cgJ10kdZATUN 9rxr1017sZvk5pqJUb43/h0Jjt6c8cxWCJlT3hs7ZFQGg3AoLB/z/aAwHhoLrQD1hxPZ S2ccu6CMnbhPe7x+/rxHpF+GfI97CPRx32e0DeBchPcw+LZlLutY+y/pgTeZGF5VWPCs XfcXR66SFWhm55KAc88xatLH95Zw434iLE4c4l7E5TuI7MGu+9Gk5aFk0i51QE2yothD vrrD7huDmjQigXTUPICkjxJebwsIVNQbaf/Ln4zR0Ho2Qhs2TAhBalo7E65TJp2w0RK6 reXw==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773702480; x=1774307280; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=jmaW4N+iY5KZojwx/299tjmKP3mLAmVNt7J+bx0Cwn4=; b=gbwIhMZYjaXbWjJqyMgp5Mo0SLWODmpb3G06a+hrLWJNiPCU7/KW4nc8yJuKQj2qEX jMWSIDlPFMAHfhTnzwrQbFDofSnUgX4mkv94DR4qwiG677rym15ilVyonmbkxyAiLIvu X1u6Nr2Mv3dSwFypgMI/UqLuAkJYR+cUzxLSIybe+WXQnE6CkcfiZTySnWvoVY4uU+uf ri0705GUorOU8Cx6efVvpfle9seOo5ZB2qhyiY1nLZJXvIM6XSBA6uE/2h+1inyhqOIO OWj+dp0ZvdFtYRTKbZ5/X9vK22QECJN+4IZcSJC4TfK1DT7AZBOTwBxAVcySsJmijh28 CkYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773702480; x=1774307280; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=jmaW4N+iY5KZojwx/299tjmKP3mLAmVNt7J+bx0Cwn4=; b=lFkYx/hnfue3z/UH1ypfDye/s+CKI+10EWflAjGuWBVRq5lvU06p8ldOKkdVcELWvw GNFs5JMmybdbYQVTpRirPn5AciF1Q7J+B+B3u9sSJTg3mi31YBaa6wgD/ZQFbHSBiUrB +3Elq99U/ERlLOYONjXGx+0OGJgjcIy9NkkSbXR3v1gtsY69+YL83n4ElIg5Jc08vVO+ ytZqELfnzki5NjfgBzi59P2dOnW9ZntH24s7qorXI7dKMvtDen3yuOM3sqHk6I2c5hF2 BxhfbcshzJdjSjvWnpKlI0DLL7JnKBqnDH6wWsrabRGsy8RmXBC2AGNNVARr6OpeLtY3 7kvA== X-Gm-Message-State: AOJu0YwryQa0HLHKTpsEE3HjG9ysoe80FwDrJCHtNABs0Gd2Lm85P1wj dajlGrS/Y1Uw7ct+dIWgkKOtvV0ML9c1YDgP3qq/CWYlXf0R++wfpg8jFcmtPEq2K+vKfZSZQPT AdJNlo/yAIlrIWppK4MY6l2B4EmUvWtclIMol X-Gm-Gg: ATEYQzzUzni1Vc7WbpzX5iBC4/KBTq55QITaUwURG7nm9W6kzqUr0DaVdnRt+mi0OZO sW3OmA9vRo6vS4viwrQ4ZQLZGJLd3dy/9La3lSDCEitgudRkZMhoAYQAyfrJjgbedvVSf/CYvUw 0cqWwFgcGAhtJ0yKKAfaz5la29JEO1EHAwtMTDdtYTv6pD6GenZs7In159rfxOkfRG8dVuHLFvu 6CXr+2GA/h3PV5CONLkMqfUQ6p4/J3PuGa0hPW59H7x56j7dgdFV7Qt8a4BOYz0A8ms6dbAfwdP 13CDP50Dh79KMvbobTybI1kvaX2O27q+vNLcnxuBaA== X-Received: by 2002:a05:6820:4687:b0:679:c3ed:c39 with SMTP id 006d021491bc7-67c04943959mr579476eaf.15.1773702480437; Mon, 16 Mar 2026 16:08:00 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Fujii Masao Date: Tue, 17 Mar 2026 08:07:47 +0900 X-Gm-Features: AaiRm511BHWr-XJ6xe4mHAp1ZTyTu0X5fMrazXgFkFS_Est_AguwtqyXbZBS9uI Message-ID: Subject: Re: Avoid resource leak (contrib/postgres_fdw/connection.c) To: Ranier Vilela Cc: Pg Hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Mar 16, 2026 at 8:46=E2=80=AFPM Ranier Vilela = wrote: > > Hi. > > Per Coverity. > > CID 1645716: (#1 of 1): Resource leak (RESOURCE_LEAK) > 8. leaked_storage: Variable str going out of scope leaks the storage str.= data points to. > > The function *postgres_fdw_connection* leaks the contents of > var str.data > Once that function *cstring_to_text* palloc the contents > must be necessary to free the var str.data. It seems that postgres_fdw_connection() is expected to be called by ForeignServerConnectionString() via OidFunctionCall3(), and to allocate memory (including str.data) in the FDWConnectionContext memory context created by ForeignServerConnectionString(). After calling postgres_fdw_connection(), ForeignServerConnectionString() deletes FDWConnectionContext. So it seems to me that any memory allocated in that context, including str.data, would not leak. No? Regards, --=20 Fujii Masao