diff options
-rw-r--r-- | src/config_file.c | 5 | ||||
-rw-r--r-- | src/pack.c | 7 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/config_file.c b/src/config_file.c index 2302d3343..e15d57bbb 100644 --- a/src/config_file.c +++ b/src/config_file.c @@ -1267,7 +1267,7 @@ static const char *escaped = "\n\t\b\"\\"; /* Escape the values to write them to the file */ static char *escape_value(const char *ptr) { - git_buf buf = GIT_BUF_INIT; + git_buf buf; size_t len; const char *esc; @@ -1277,7 +1277,8 @@ static char *escape_value(const char *ptr) if (!len) return git__calloc(1, sizeof(char)); - git_buf_grow(&buf, len); + if (git_buf_init(&buf, len) < 0) + return NULL; while (*ptr != '\0') { if ((esc = strchr(escaped, *ptr)) != NULL) { diff --git a/src/pack.c b/src/pack.c index d24c13815..f8d0dc9ac 100644 --- a/src/pack.c +++ b/src/pack.c @@ -312,7 +312,7 @@ static int pack_index_open(struct git_pack_file *p) { int error = 0; size_t name_len; - git_buf idx_name = GIT_BUF_INIT; + git_buf idx_name; if (p->index_version > -1) return 0; @@ -320,10 +320,13 @@ static int pack_index_open(struct git_pack_file *p) name_len = strlen(p->pack_name); assert(name_len > strlen(".pack")); /* checked by git_pack_file alloc */ - git_buf_grow(&idx_name, name_len); + if (git_buf_init(&idx_name, name_len) < 0) + return -1; + git_buf_put(&idx_name, p->pack_name, name_len - strlen(".pack")); git_buf_puts(&idx_name, ".idx"); if (git_buf_oom(&idx_name)) { + git_buf_free(&idx_name); return -1; } |