diff options
author | Russell Belfer <rb@github.com> | 2012-07-19 21:23:45 +0400 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2012-07-19 21:23:45 +0400 |
commit | 71d273583755c0a2b7f5d608f017f4586add51e4 (patch) | |
tree | 9a70607c88d126591a5fc7241987e5d410e3bf0f /src/pool.c | |
parent | 5a8204f8a88c59c2cb07b93930834ef0a5aaf1fc (diff) |
Fix bug with merging diffs with null options
A diff that is created with a NULL options parameter could result
in a NULL prefix string, but diff merge was unconditionally
strdup'ing it. I added a test to replicate the issue and then a
new method that does the right thing with NULL values.
Diffstat (limited to 'src/pool.c')
-rw-r--r-- | src/pool.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/pool.c b/src/pool.c index 63bf09cee..64b5c6b00 100644 --- a/src/pool.c +++ b/src/pool.c @@ -206,6 +206,11 @@ char *git_pool_strdup(git_pool *pool, const char *str) return git_pool_strndup(pool, str, strlen(str)); } +char *git_pool_strdup_safe(git_pool *pool, const char *str) +{ + return str ? git_pool_strdup(pool, str) : NULL; +} + char *git_pool_strcat(git_pool *pool, const char *a, const char *b) { void *ptr; |