From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by sourceware.org (Postfix) with ESMTPS id C6E5D385DC0B for ; Wed, 13 Sep 2023 06:50:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C6E5D385DC0B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-26fb8225268so4388091a91.1 for ; Tue, 12 Sep 2023 23:50:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694587828; x=1695192628; darn=sourceware.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=bAe4vJJeTRcnWp28qBSHhG/J+hC8lm9U1BL365DYk1w=; b=AGf4QhQ2L4AuFihJ8V3a+U4f6a2VBbC73EYdHLii9zVMpNcdsBfCpk/Oc8IsJFrZuY Zz7inIjCHC61oPbtXkyxQRYh/9qno48rBuTVHsEC2XGCPVY1YONVYOrd/RtKw8yAV6ls nNQmAxRZU99oZgQhpep1BCzKWmv5l6d/abuOKiiHLULsYETeFPNNqWrilvBeK8y1V1pi LFFhrSdESze34KwTTvyz5Khvuf541eHgs79NuKa4u6XEAMv+1uTYy/3WPlKPEyzQT6+J SzBJvtG1yidmkuI9ehZ0iUJpcN0ZVHbp1Q8C4+RoeR97is7r829/gSaodEHxEA/kKVWN IIKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694587828; x=1695192628; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=bAe4vJJeTRcnWp28qBSHhG/J+hC8lm9U1BL365DYk1w=; b=Tjcrk7mW5p6offPP6Qa45WC4l6EtvlWa1DDA6jw2TfE0ljyYtxGg++BXSJjeHL4Gq2 Ok84aodW2XY+tbMW7/JaYMrfdipgUX6B4Nse+HhagqwU3pGvaKUMquSf4Mk2gklELNoM qcwNHN/yPGKP7UPMJ74Ho6AqR4sY0o0i2gGScwEOJl0da7wxy/jrZ3OXQvPno4nyKaPw YatJD5h1ggXqOsv/7K3xpGKNQMOCL1Ox/57puKb0F9KbrKTdB/ZCM2kk1bqqEIxaPrl/ f/gcm4OeCH7OD/hUIDiEhq/PjTVIWOP5Sodi7TxjAxQu/KaWe3AvR0qfeRbPoGgwb6c/ Qxtw== X-Gm-Message-State: AOJu0Yy4dienwvtUFRmowL023xV8I/8JAoMbW4IzdGQ7K1x/m8Qn1HNW r8suNJMPYwq1MUbERKys6wpaD1TIbs8= X-Google-Smtp-Source: AGHT+IE+t7FIFcYWtaFurbxXapsN8QETaIZBNJ7G8+40kKgr5/YR0qpyoJYrG+vYfz5RKZXUmNgZoA== X-Received: by 2002:a17:90b:17c4:b0:267:fba3:ed96 with SMTP id me4-20020a17090b17c400b00267fba3ed96mr1323570pjb.3.1694587827819; Tue, 12 Sep 2023 23:50:27 -0700 (PDT) Received: from squeak.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id z91-20020a17090a6d6400b0025c1cfdb93esm789442pjj.13.2023.09.12.23.50.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 23:50:27 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id C1C391140B5B; Wed, 13 Sep 2023 16:20:24 +0930 (ACST) Date: Wed, 13 Sep 2023 16:20:24 +0930 From: Alan Modra To: jacob navia Cc: binutils@sourceware.org Subject: Re: Missing NULL check Message-ID: References: <69AA9E49-F26A-4DAC-B120-70940C3A59B1@jacob.remcomp.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <69AA9E49-F26A-4DAC-B120-70940C3A59B1@jacob.remcomp.fr> X-Spam-Status: No, score=-3028.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, Sep 12, 2023 at 05:40:45PM +0200, jacob navia wrote: > Add > if (list == NULL) return NULL; Yes, we should be testing for a NULL return from bfd_alloc, but error handling then needs to be propagated up the call chain. If elf_new_obj_attr returns NULL then all its callers will segfault unless they are changed too. We also don't want to hide allocation failures which means functions like bfd_elf_add_obj_attr_int should return the obj_attribute pointer rather than void, and all callers should check the return value. I'll write a patch to do that. -- Alan Modra Australia Development Lab, IBM