~herrhotzenplotz/gcli-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH gcli] Fix segmentation fault when showing pull request on Gitea under some conditions

Details
Message ID
<20240613124217.10931-1-nsonack@herrhotzenplotz.de>
DKIM signature
pass
Download raw message
Patch: +15 -1
Whenever a pull request is submitted on Gitea and it has the project
owners set as reviewers (not one by one but just a generic everyone)
the reviewers array contains a single NULL which is being dereferenced
later.

Fix by replacing NULLs in the retrieved array by a malloced string
stating the project owners as reviewers.

Fixes: https://gitlab.com/herrhotzenplotz/gcli/issues/222
Signed-off-by: Nico Sonack <nsonack@herrhotzenplotz.de>
---
 src/gitea/pulls.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/gitea/pulls.c b/src/gitea/pulls.c
index 7489c58..707ba8b 100644
--- a/src/gitea/pulls.c
+++ b/src/gitea/pulls.c
@@ -100,7 +100,21 @@ int
gitea_get_pull(struct gcli_ctx *ctx, char const *owner, char const *repo,
               gcli_id const pr_number, struct gcli_pull *const out)
{
	return github_get_pull(ctx, owner, repo, pr_number, out);
	int const rc = github_get_pull(ctx, owner, repo, pr_number, out);

	if (rc == 0) {
		/* fix for https://gitlab.com/herrhotzenplotz/gcli/issues/222:
		 *
		 * Sometimes the "reviewers" array contains a single NULL value
		 * that means that this pull request is to be reviewed by the
		 * owners of the repository. */
		for (size_t i = 0; i < out->reviewers_size; ++i) {
			if (out->reviewers[i] == NULL)
				out->reviewers[i] = sn_asprintf("%s/Owners", owner);
		}
	}

	return rc;
}

int
-- 
2.44.0
Details
Message ID
<D1YWNDVOBFZ6.3KDVN2LCKH37F@gjnoonan.co.uk>
In-Reply-To
<20240613124217.10931-1-nsonack@herrhotzenplotz.de> (view parent)
DKIM signature
pass
Download raw message
Applied. Thanks

-g
Reply to thread Export thread (mbox)