summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2018-08-16 10:35:31 +0200
committerGitHub <noreply@github.com>2018-08-16 10:35:31 +0200
commit622e12c1b26210d5fb2f1136a3ab4d3c81c1d2c8 (patch)
treedd8a1e8a36603032d8030073e3af39708f82007e /src
parent43e7bf78aa28b8a5bc43f0f3ba91b06d98ca6b70 (diff)
parentd1bfe614aa20a0bdaf76c6d418176320ab11baf4 (diff)
downloadlibgit2-622e12c1b26210d5fb2f1136a3ab4d3c81c1d2c8.tar.gz
Merge pull request #4749 from neithernut/fix-git__linenlen-ub
parse: Do not initialize the content in context to NULL
Diffstat (limited to 'src')
-rw-r--r--src/parse.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/parse.c b/src/parse.c
index 6b8902c35..b04fda36b 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -8,12 +8,14 @@
int git_parse_ctx_init(git_parse_ctx *ctx, const char *content, size_t content_len)
{
- if (content_len)
+ if (content && content_len) {
ctx->content = content;
- else
- ctx->content = NULL;
+ ctx->content_len = content_len;
+ } else {
+ ctx->content = "";
+ ctx->content_len = 0;
+ }
- ctx->content_len = content_len;
ctx->remain = ctx->content;
ctx->remain_len = ctx->content_len;
ctx->line = ctx->remain;
@@ -26,6 +28,7 @@ int git_parse_ctx_init(git_parse_ctx *ctx, const char *content, size_t content_l
void git_parse_ctx_clear(git_parse_ctx *ctx)
{
memset(ctx, 0, sizeof(*ctx));
+ ctx->content = "";
}
void git_parse_advance_line(git_parse_ctx *ctx)