diff options
author | Ramsay Jones <ramsay@ramsay1.demon.co.uk> | 2008-12-27 18:56:16 +0000 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2008-12-30 07:32:16 -0800 |
commit | 42fd40db68e5e5797531dc1f5de7aef39a2262c0 (patch) | |
tree | d7a09674532ffc0bda73e7c6e028bb78120c85e6 /src/commit.h | |
parent | d7fbfe155fbddb41936407612fbce9c34276b671 (diff) | |
download | libgit2-42fd40db68e5e5797531dc1f5de7aef39a2262c0.tar.gz |
Fix a bug in gitfo_read_file()
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>
Diffstat (limited to 'src/commit.h')
0 files changed, 0 insertions, 0 deletions