]> git.ipfire.org Git - thirdparty/git.git/commit - merge.c
Always check `parse_tree*()`'s return value
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Fri, 23 Feb 2024 08:34:23 +0000 (08:34 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 23 Feb 2024 18:19:40 +0000 (10:19 -0800)
commitaa9f618909d30e3f0c7181243e89a81220507e6e
treeeba8780bfd3266fc0fc9371a0e9024d92d04b036
parent98c6d16d6746059dc1e1183f8f8366eef2a41eff
Always check `parse_tree*()`'s return value

Otherwise we may easily run into serious crashes: For example, if we run
`init_tree_desc()` directly after a failed `parse_tree()`, we are
accessing uninitialized data or trying to dereference `NULL`.

Note that the `parse_tree()` function already takes care of showing an
error message. The `parse_tree_indirectly()` and
`repo_get_commit_tree()` functions do not, therefore those latter call
sites need to show a useful error message while the former do not.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 files changed:
builtin/checkout.c
builtin/clone.c
builtin/commit.c
builtin/merge-tree.c
builtin/read-tree.c
builtin/reset.c
cache-tree.c
merge-ort.c
merge-recursive.c
merge.c
reset.c
sequencer.c