devel/arcanist-lib: Handle NULL argument passed to strlen()

Problem description:

- ArcanistDiffWorkflow.php:getDiffOntoTargets() tries to determine the
  current branch name by calling ArcanistGitAPI.php:getBranchName()

- getBranchName() returns NULL when working on a detached HEAD

- getDiffOntoTargets() calls strlen() with the branch name, which now
  fails with a NULL argument.

Approved by:	grembo (maintainer)
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Joseph Mingrone 2023-01-09 17:27:58 -04:00
parent 5d0279df7a
commit 3b71507307
No known key found for this signature in database
GPG Key ID: 36A40C83B0D6EF9E
2 changed files with 12 additions and 1 deletions

View File

@ -1,6 +1,6 @@
PORTNAME?= arcanist PORTNAME?= arcanist
PORTVERSION?= 20220518 PORTVERSION?= 20220518
PORTREVISION?= 2 PORTREVISION?= 3
CATEGORIES?= devel CATEGORIES?= devel
PKGNAMESUFFIX= ${SLAVE_PKGNAMESUFFIX}${PHP_PKGNAMESUFFIX} PKGNAMESUFFIX= ${SLAVE_PKGNAMESUFFIX}${PHP_PKGNAMESUFFIX}

View File

@ -0,0 +1,11 @@
--- src/workflow/ArcanistDiffWorkflow.php.orig 2023-01-09 21:24:25 UTC
+++ src/workflow/ArcanistDiffWorkflow.php
@@ -2361,7 +2361,7 @@ EOTEXT
// If we track an upstream branch either directly or indirectly, use that.
$branch = $api->getBranchName();
- if (strlen($branch)) {
+ if (strlen($branch ?? '')) {
$upstream_path = $api->getPathToUpstream($branch);
$remote_branch = $upstream_path->getRemoteBranchName();
if ($remote_branch !== null) {