mirror of
https://github.com/git/git.git
synced 2026-01-28 11:32:24 +00:00
While the xdiff machinery is quite capable of working with strings given as pointer and size, Git's add-on functionality simply assumes that we are operating on NUL-terminated strings, e.g. y running regexec() on the provided pointer, with no way to pass the size, too. In general, this assumption is wrong. It is true that many code paths populate the mmfile_t structure silently appending a NUL, e.g. when running textconv on a temporary file and reading the results back into an strbuf. The assumption is most definitely wrong, however, when mmap()ing a file. Practically, we seemed to be lucky that the bytes after mmap()ed memory were 1) accessible and 2) somehow contained NUL bytes *somewhere*. In a use case reported by Chris Sidi, it turned out that the mmap()ed file had the precise size of a memory page, and on Windows the bytes after memory-mapped pages are in general not valid. This patch works around that issue, giving us time to discuss the best course how to fix this problem more generally. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
139 KiB
139 KiB