All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Kleber Tarcísio via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: "Kleber Tarcísio" <klebertarcisio@yahoo.com.br>,
	"Kleber Tarcísio" <klebertarcisio@yahoo.com.br>
Subject: [PATCH] fix null pointer dereference
Date: Sun, 21 Mar 2021 10:52:16 +0000	[thread overview]
Message-ID: <pull.983.git.git.1616323936790.gitgitgadget@gmail.com> (raw)

From: =?UTF-8?q?Kleber=20Tarc=C3=ADsio?= <klebertarcisio@yahoo.com.br>

The malloc function can return null when the memory allocation fails. This commit adds a condition to handle these cases properly. https://cwe.mitre.org/data/definitions/476.html

Signed-off-by: Kleber Tarcísio <klebertarcisio@yahoo.com.br>
---
    Avoiding null pointer dereference
    
    This pull request aims to fix null pointer dereference.
    
    Null pointer dereference
    [https://cwe.mitre.org/data/definitions/476.html]

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-983%2Fklebertarcisio%2Fpatch-1-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-983/klebertarcisio/patch-1-v1
Pull-Request: https://github.com/git/git/pull/983

 builtin/submodule--helper.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 9d505a6329c8..92349d715a78 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -1215,6 +1215,8 @@ static void submodule_summary_callback(struct diff_queue_struct *q,
 		if (!S_ISGITLINK(p->one->mode) && !S_ISGITLINK(p->two->mode))
 			continue;
 		temp = (struct module_cb*)malloc(sizeof(struct module_cb));
+		if (!temp) 
+			die(_("out of memory"));
 		temp->mod_src = p->one->mode;
 		temp->mod_dst = p->two->mode;
 		temp->oid_src = p->one->oid;

base-commit: a5828ae6b52137b913b978e16cd2334482eb4c1f
-- 
gitgitgadget

             reply	other threads:[~2021-03-21 10:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-21 10:52 Kleber Tarcísio via GitGitGadget [this message]
2021-03-21 12:43 ` [PATCH] fix null pointer dereference Ævar Arnfjörð Bjarmason
2021-03-21 14:47 ` Matheus Tavares Bernardino
2021-03-21 17:25 ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=pull.983.git.git.1616323936790.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=klebertarcisio@yahoo.com.br \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.