1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-09 18:26:08 +02:00

fix null pointer dereference

The malloc function can return null when the memory allocation fails.
This commit uses xmalloc to fix it.
https://cwe.mitre.org/data/definitions/476.html

Signed-off-by: Kleber Tarcísio <klebertarcisio@yahoo.com.br>
This commit is contained in:
Kleber Tarcísio 2022-01-18 23:16:39 -03:00
parent a5828ae6b5
commit 8d205037e0

View File

@ -1214,7 +1214,7 @@ 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));
temp = (struct module_cb*)xmalloc(sizeof(struct module_cb));
temp->mod_src = p->one->mode;
temp->mod_dst = p->two->mode;
temp->oid_src = p->one->oid;