From patchwork Thu Jan 19 03:42:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Borowski X-Patchwork-Id: 1728554 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=angband.pl header.i=@angband.pl header.a=rsa-sha256 header.s=tartarus header.b=WPrLEOfe; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Ny7l40gGHz23gL for ; Thu, 19 Jan 2023 14:43:28 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8EBEB3858416 for ; Thu, 19 Jan 2023 03:43:25 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from tartarus.angband.pl (tartarus.angband.pl [51.83.246.204]) by sourceware.org (Postfix) with ESMTPS id 9CA7F3858D28 for ; Thu, 19 Jan 2023 03:43:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9CA7F3858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=angband.pl Authentication-Results: sourceware.org; spf=none smtp.mailfrom=valinor.angband.pl DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=angband.pl; s=tartarus; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=WYbv5GMOXJOV3/8IvUsKBqGwzuv1IWIjXjc0/sgDcnI=; b=WPrLEOfeIKJH5SKNsNiukV5Aq3 IHD/N2X7u0B3dLaCmMNvnB2jUI99nF1VD2qyThjv+KVgojGy35UFWYVbo9MmkHo09up+/GXSGv0+I MtST59dCmA59/N/nNCvY5kGi9YD6WxsoMJm36Lt3nDioeORaW6mVry0bfd2dnMMrs0Kw=; Received: from localhost ([127.0.0.1] helo=valinor.angband.pl) by tartarus.angband.pl with smtp (Exim 4.94.2) (envelope-from ) id 1pILpU-00F3qS-1f; Thu, 19 Jan 2023 04:43:08 +0100 Received: (nullmailer pid 15899 invoked by uid 1000); Thu, 19 Jan 2023 03:43:07 -0000 From: Adam Borowski To: libc-alpha@sourceware.org Cc: Adam Borowski Subject: [PATCH] asprintf: set result ptr to NULL on error Date: Thu, 19 Jan 2023 04:42:58 +0100 Message-Id: <20230119034258.15881-1-kilobyte@angband.pl> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: kilobyte@valinor.angband.pl X-SA-Exim-Scanned: No (on tartarus.angband.pl); SAEximRunCond expanded to false X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" This is what other implementations do, and it's too easy to assume this is being done. Thus, let's avoid a footgun. Signed-off-by: Adam Borowski --- libio/vasprintf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libio/vasprintf.c b/libio/vasprintf.c index facc224295..d56a839fe1 100644 --- a/libio/vasprintf.c +++ b/libio/vasprintf.c @@ -95,6 +95,7 @@ int __vasprintf_internal (char **result_ptr, const char *format, va_list args, unsigned int mode_flags) { + *result_ptr = NULL; struct __printf_buffer_asprintf buf; __printf_buffer_init (&buf.base, buf.direct, array_length (buf.direct), __printf_buffer_mode_asprintf);