From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by sourceware.org (Postfix) with ESMTPS id AA8813841884 for ; Tue, 7 Jun 2022 21:24:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AA8813841884 Received: by mail-lj1-x234.google.com with SMTP id g25so20604151ljm.2 for ; Tue, 07 Jun 2022 14:24:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pZVIJNNmn6uJpyFunTjqnNnOPRFZAmKK1316Ko8hkcg=; b=IM6/0KZDMcwOAi9uLU7iADCMPaJa44yrVJjGf4rJovr3vIMj9ymrNDQwx2r2+H64Ma QVHKtC8vOUu57E9kiqD4F7LnnBa9ajhcVJyOj2+GvR3A8JSjrS49H0JF5tbxPsKq2AJw t6+WAWfFMq1sMJqHqQzjmE/Fk02qITecNMWo88njrNm+L25ZFr4nS10R9s+x047EUiAF yFQJF5Ow+OI7uXmobw75TgIp1hOIa/yBkk8pfahJLUWSdwOiUbTVVC/3enbndxQMqYje +nlyPJ17pAzzwcGaeyotkRhPgpMtGgMfwA3QZXNPGD9rPQuf9auLekdly5ejPzrylCjO QRuA== X-Gm-Message-State: AOAM531SKHof00WxB9sdWZ/8UEbAN0468DRtB4s//RTgfFDJCQibnrpn WW4IxDtSWuoBDMsYWaXI3Nn0PNXUT0H5nQ== X-Google-Smtp-Source: ABdhPJwg4t1440LQjhgRuMgnZyF8MMvENYCKOJ4NGe49WVV7HwzwTPSfkWXdPwJZuR27wZQVNPubcA== X-Received: by 2002:a2e:8449:0:b0:24f:4db3:f02e with SMTP id u9-20020a2e8449000000b0024f4db3f02emr55713919ljh.140.1654637067203; Tue, 07 Jun 2022 14:24:27 -0700 (PDT) Received: from localhost.localdomain (c188-151-104-159.bredband.tele2.se. [188.151.104.159]) by smtp.gmail.com with ESMTPSA id p17-20020a2ea4d1000000b0025530fa4edesm3016626ljm.49.2022.06.07.14.24.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 14:24:22 -0700 (PDT) From: Marcus Nilsson To: binutils@sourceware.org Subject: [PATCH] readelf: Replace xmalloc with malloc in slurp_relr_relocs Date: Tue, 7 Jun 2022 23:23:43 +0200 Message-Id: <20220607212342.671687-1-brainbomb@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Jun 2022 21:24:30 -0000 Using xmalloc makes the null check redundant since failing allocation will exit the program. Instead use malloc and let the error be conveyed up the call chain. binutils/ChangeLog: * readelf.c: (slurp_relr_relocs) Use malloc instead of xmalloc when allocating space for relocations. --- binutils/readelf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/binutils/readelf.c b/binutils/readelf.c index 4c0a2a34767..fe0d27decc3 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -1401,7 +1401,7 @@ slurp_relr_relocs (Filedata * filedata, size++; } - *relrsp = (bfd_vma *) xmalloc (size * sizeof (bfd_vma)); + *relrsp = (bfd_vma *) malloc (size * sizeof (bfd_vma)); if (*relrsp == NULL) { free (relrs); -- 2.34.1