- Uninitialised jsongen in gcli-forks causes an infinite loop in fit(), where
capacity is doubled until a string fits, but capacity is 0 so doubling does
nothing
- Also change what looks to me like unbalanced gcli_jsongen_{begin,end}_*
calls in src/github/issues.c
---
src/github/forks.c | 1 +
src/github/issues.c | 4 ++--
src/gitlab/forks.c | 1 +
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/github/forks.c b/src/github/forks.c
index 96a9a6f1..c84cc1ca 100644
--- a/src/github/forks.c
+++ b/src/github/forks.c
@@ -76,6 +76,7 @@ github_fork_create(struct gcli_ctx *ctx,
if (in) {
struct gcli_jsongen gen = {0};
+ gcli_jsongen_init(&gen);
gcli_jsongen_begin_object(&gen);
{
gcli_jsongen_objmember(&gen, "organization");
diff --git a/src/github/issues.c b/src/github/issues.c
index 88cf8bbb..2de9e10e 100644
--- a/src/github/issues.c
+++ b/src/github/issues.c
@@ -416,7 +416,7 @@ github_perform_submit_issue(struct gcli_ctx *const ctx,
gcli_jsongen_string(&gen, opts->body);
}
}
- gcli_jsongen_begin_object(&gen);
+ gcli_jsongen_end_object(&gen);
payload = gcli_jsongen_to_string(&gen);
gcli_jsongen_free(&gen);
@@ -471,7 +471,7 @@ github_issue_assign(struct gcli_ctx *ctx, struct gcli_path const *const path,
gcli_jsongen_objmember(&gen, "assignees");
gcli_jsongen_begin_array(&gen);
gcli_jsongen_string(&gen, assignee);
- gcli_jsongen_end_object(&gen);
+ gcli_jsongen_end_array(&gen);
}
gcli_jsongen_end_object(&gen);
diff --git a/src/gitlab/forks.c b/src/gitlab/forks.c
index 22fc7027..0b858309 100644
--- a/src/gitlab/forks.c
+++ b/src/gitlab/forks.c
@@ -75,6 +75,7 @@ gitlab_fork_create(struct gcli_ctx *ctx,
if (in) {
struct gcli_jsongen gen = {0};
+ gcli_jsongen_init(&gen);
gcli_jsongen_begin_object(&gen);
{
gcli_jsongen_objmember(&gen, "namespace_path");
--
2.47.1
> - Uninitialised jsongen in gcli-forks causes an infinite loop in fit(), where
> capacity is doubled until a string fits, but capacity is 0 so doubling does
> nothing
> - Also change what looks to me like unbalanced gcli_jsongen_{begin,end}_*
> calls in src/github/issues.c
Good catch! Thanks for the patch, I have applied it.
I'm gonna update the Changelog later as well.
Nico
> - Uninitialised jsongen in gcli-forks causes an infinite loop in fit(), where
> capacity is doubled until a string fits, but capacity is 0 so doubling does
> nothing
> - Also change what looks to me like unbalanced gcli_jsongen_{begin,end}_*
> calls in src/github/issues.c
Actually, no that I am thinking about this... maybe I should change
the return type of the jsongen* functions to void and simply assert
that whatever we pop off the scope stack is of the correct type.
Another solution is to simply add assertions in various places
(which are removed if compiled in non-debug mode).
I'll work on a patch for likely solution #2.
Nico