Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ppUL1-0004xL-MZ for pgsql-committers@arkaria.postgresql.org; Thu, 20 Apr 2023 13:28:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ppUL0-0000eh-3H for pgsql-committers@arkaria.postgresql.org; Thu, 20 Apr 2023 13:28:38 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ppUKz-0000eY-Ry for pgsql-committers@lists.postgresql.org; Thu, 20 Apr 2023 13:28:37 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ppUKt-000snS-2f; Thu, 20 Apr 2023 13:28:36 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 33KDSTrF3129479; Thu, 20 Apr 2023 09:28:29 -0400 From: Tom Lane To: David Rowley cc: pgsql-committers@lists.postgresql.org Subject: Re: pgsql: Fix list_copy_head() with empty Lists In-reply-to: References: Comments: In-reply-to David Rowley message dated "Wed, 19 Apr 2023 22:35:03 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3129477.1681997309.1@sss.pgh.pa.us> Date: Thu, 20 Apr 2023 09:28:29 -0400 Message-ID: <3129478.1681997309@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Rowley writes: > Fix list_copy_head() with empty Lists > list_copy_head() given an empty List would crash from trying to > dereference the List to obtain its length. Since NIL is how we represent > an empty List, we should just be returning another empty List in this > case. I see that list_copy_head exists in v15 as well. It appears to have no callers there, but we'd better fix it anyway in case somebody back-patches a fix that uses it. Or, maybe, remove it in 15? regards, tom lane