diff options
| author | Siddharth Shrimali <r.siddharth.shrimali@gmail.com> | 2026-03-10 22:14:12 +0530 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2026-03-11 11:17:56 -0700 |
| commit | 35f220b639849d43cd8aaae34ccbe38e9935ab2b (patch) | |
| tree | ab0871eb7bc0396ba49bb3e82e70949741d7b3d6 /builtin | |
| parent | 67ad42147a7acc2af6074753ebd03d904476118f (diff) | |
| download | git-35f220b639849d43cd8aaae34ccbe38e9935ab2b.tar.xz | |
submodule--helper: replace malloc with xmalloc
The submodule_summary_callback() function currently uses a raw malloc()
which could lead to a NULL pointer dereference.
Standardize this by replacing malloc() with xmalloc() for error handling.
To improve maintainability, use sizeof(*temp) instead of the struct name,
and drop the typecast of void pointer assignment.
Signed-off-by: Siddharth Shrimali <r.siddharth.shrimali@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
| -rw-r--r-- | builtin/submodule--helper.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index d537ab087a..20dd9d04b6 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -1059,7 +1059,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 = xmalloc(sizeof(*temp)); temp->mod_src = p->one->mode; temp->mod_dst = p->two->mode; temp->oid_src = p->one->oid; |
