Please sign in to comment.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
read_entryto return entry size via an out-param
The function `read_entry` does not conform to our usual coding style of returning stuff via the out parameter and to use the return value for reporting errors. Due to most of our code conforming to that pattern, it has become quite natural for us to actually return `-1` in case there is any error, which has also slipped in with commit 5625d86 (index: support index v4, 2016-05-17). As the function returns an `size_t` only, though, the return value is wrapped around, causing the caller of `read_tree` to continue with an invalid index entry. Ultimately, this can lead to a double-free. Improve code and fix the bug by converting the function to return the index entry size via an out parameter and only using the return value to indicate errors. Reported-by: Krishna Ram Prakash R <firstname.lastname@example.org> Reported-by: Vivek Parikh <email@example.com>
- Loading branch information
Showing with 13 additions and 9 deletions.
- +13 −9 src/index.c