mirror of
https://git.proxmox.com/git/libgit2
synced 2025-12-30 22:59:52 +00:00
In particular, when asked to read an empty file, this function calls malloc() with a zero size allocation request. Standard C says that the behaviour of malloc() in this case is implementation defined. [C99, 7.20.3 says "... If the size of the space requested is zero, the behavior is implementation-defined: either a null pointer is returned, or the behavior is as if the size were some nonzero value, except that the returned pointer shall not be used to access an object."] Finesse the issue by over-allocating by one byte. Setting the extra byte to '\0' may also provide a useful sentinel for text files. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Shawn O. Pearce <spearce@spearce.org> |
||
|---|---|---|
| src | ||
| tests | ||
| .gitignore | ||
| .HEADER | ||
| api.doxygen | ||
| CONVENTIONS | ||
| COPYING | ||
| git.git-authors | ||
| libgit2.pc.in | ||
| Makefile | ||