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 1w28kK-0001ac-1z for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Mar 2026 14:16:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w28kI-00ALyk-1n for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Mar 2026 14:16:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w28kI-00ALyc-0o for pgsql-hackers@lists.postgresql.org; Mon, 16 Mar 2026 14:16:39 +0000 Received: from mail-dy1-x132d.google.com ([2607:f8b0:4864:20::132d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w28kG-00000000R9D-1VfM for pgsql-hackers@postgresql.org; Mon, 16 Mar 2026 14:16:38 +0000 Received: by mail-dy1-x132d.google.com with SMTP id 5a478bee46e88-2beb0246931so4895443eec.0 for ; Mon, 16 Mar 2026 07:16:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773670595; x=1774275395; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=Uo641DQQklt7cZyNKAeP7jNAfNocj9mI5picCcyEovQ=; b=C69Yy01D06/b9/nEIcYHox7izQ75e9Fsb0Rlw9mzc//BlQXQM6mmbHM3rMqI4CNKlT LPthVz6FoE7KPCOPczGZKVtW5e6sIsAjKdnu8emrfcVB0Lbh0Bzo5+e9ysQ8bJV/Bc9W 8lhYqIRKSXH4vLEuaScJjD/cTOb15gmRpytEDCJPeaLPsj9Zijp9G1UxIjcxc7hVkhCD bpIKIN+nTyih/ilhqL1UT6lN9/LMTiBjK6zvMueIYJkXjZizGzZH3s8LVPgrj/cK97+y k69EQNxvCQmUpCNRxCoA4Wut3GGZLK50ReGBr59SqnnUpDQ8cqdKcq5hsFChGjOsGdON nRLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773670595; x=1774275395; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Uo641DQQklt7cZyNKAeP7jNAfNocj9mI5picCcyEovQ=; b=K95YDlmkaE7HDPivQoem4XWO3eTBr46RVe1E1Goh7nMfxM8drpBpWwdMlTsoEf0+9v +Xn6yqbq+z52/Zm2xqVQb2IA+S2Kl64p8sr2xdZhF5rREcFSMkwdyzE2beYF361Q/Gdc b/lH/avmcsTQTGCBgYXZtCss2TwzIyeJyt7LK9DLfnfcD0mPgWyksi76Z1LOxMz5d2wj yR+nqOSBKH2SyBzJ6Dv9ZM1GyZVQ/I4znjeYI/ZXTln2RxdBn7qE+3m1YE88CzIxPQ+E LdovGWeZ+xxm/pMoRhoNttGRps0YttmQl9G8tl5COLaV8gRk/5tbFvQXqTAwJVF2dohq UT6Q== X-Forwarded-Encrypted: i=1; AJvYcCXgFjSeJzo2mH9E4mweWC2ubyJSLO5BXtU8sL0MQWTopvNu9hz07KzNE9wLCm+I7BzDVscM23Hq4vvbX0Da@postgresql.org X-Gm-Message-State: AOJu0Yy1ND3dKZldQ73nOB4FtaRB4qhGfJ6fk+8KtSU07W+7eVK7xpUB 3V4VIv7d/KhZtjiPjjyzyFoHadTw8ti7RnF10X0pGIbNiHrveSN/qQ6k X-Gm-Gg: ATEYQzyZ2uSAAuq1U6Xl2OjrwIX+luV2rffheVplwaJKIJJSXHDXRLw0WuSZikb0IgJ noA/giy2/UJ5ys1F9CkU16onUhwHsZS2qQFD9Ie/hpyO+3sdj+6dMeexhLM/8TAhfl3onIy4tVC GqChpw9ZNnPpSlEy2gPPtQJEAFszh5Ip+axFi8zCGUgq2KJn61XX8ou5TIq4FcSQ+ARMT2tRhOw i8JFPWi3fmEgzanFPvYaqQKBBMsKgWXhngiecicONe++EZw7leCpyeHf/efU61XfuLydzHAYmNo rZfl3JaT0e01y1WQV5VQcxPn9+6s9AOBpmL6KB9MSeEDI5Rjqeb8Kq405f+alJ9mjltlXKP4FYG pNWWaPW9u25CDZ7tUElBP+lq4X6sOKbU09CQfPznpGGX0UsLnMqdiQmnGwQPEWjBFXqDyvwDuV/ 2FLPnYH+Ty9ANmFZZ08Lh/7BpCBjD4ooDf3YMkaPL5TvjIUNxlKLbLD6kmMC7M1NQ35F6tFyMza 3sBPojwTlNCctaCi06SSw== X-Received: by 2002:a05:7300:730e:b0:2be:ca4:e144 with SMTP id 5a478bee46e88-2bea558034emr6586895eec.31.1773670594546; Mon, 16 Mar 2026 07:16:34 -0700 (PDT) Received: from ?IPV6:2804:14d:328a:a59c:78ea:5704:c9d6:c77b? ([2804:14d:328a:a59c:78ea:5704:c9d6:c77b]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2beab3eec8fsm14577431eec.13.2026.03.16.07.16.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 16 Mar 2026 07:16:32 -0700 (PDT) Message-ID: Date: Mon, 16 Mar 2026 11:16:30 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Avoid resource leak (contrib/postgres_fdw/connection.c) To: Ranier Vilela , Pg Hackers References: Content-Language: en-US From: Matheus Alcantara In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 16/03/26 08:45, 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. > > patch attached. > Hi, Thanks for the patch, it looks correct to me. I've searched for this pattern `PG_RETURN_TEXT_P(cstring_to_text(.*.data` in other places and I've just found on postgres_fdw/connection.c I've also search for other cases of `return cstring_to_text(...)` usages and I didn't found anything that seems suspicious. Tests are also passing. -- Matheus Alcantara EDB: https://www.enterprisedb.com