Commit 95cd8353 by Vicent Martí

Merge pull request #1105 from delanne/invalid_read_config_file

Fix invalid read reported by valgrind
parents c4d8df27 f2696fa4
......@@ -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