Commit f2696fa4 by delanne

Fix invalid read reported by valgrind

parent c4d8df27
......@@ -1220,7 +1220,7 @@ static int config_write(diskfile_backend *cfg, const char *key, const regex_t *p
}
/* If we are here, there is at least a section line */
if (*(cfg->reader.buffer.ptr + cfg->reader.buffer.size - 1) != '\n')
if (cfg->reader.buffer.size > 0 && *(cfg->reader.buffer.ptr + cfg->reader.buffer.size - 1) != '\n')
git_filebuf_write(&file, "\n", 1);
git_filebuf_printf(&file, "\t%s = %s\n", name, value);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment