From 8b907d7716617989d9d30ddbb3152307560cd36d Mon Sep 17 00:00:00 2001 From: sten Date: Fri, 18 Aug 2023 10:01:00 +0100 Subject: [PATCH] Fix PHP 8.1 arc patch strlen(null) binary file error Summary: Fix issue in arcanist whereby when doing an arc patch involving adding or removing a binary file, it falls over with strlen(null) errors. Fixes T15617 Test Plan: arc patch Dxxxx Reviewers: O1 Blessed Committers, avivey Reviewed By: O1 Blessed Committers, avivey Subscribers: avivey, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15617 Differential Revision: https://we.phorge.it/D25409 --- src/parser/ArcanistBundle.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/parser/ArcanistBundle.php b/src/parser/ArcanistBundle.php index 4617c9b6..62deca5e 100644 --- a/src/parser/ArcanistBundle.php +++ b/src/parser/ArcanistBundle.php @@ -762,7 +762,7 @@ final class ArcanistBundle extends Phobject { $old_data = $this->getBlob($old_phid, $name); } - $old_length = strlen($old_data); + $old_length = phutil_nonempty_string($old_data) ? strlen($old_data) : 0; // Here, and below, the binary will be emitted with base85 encoding. This // encoding encodes each 4 bytes of input in 5 bytes of output, so we may @@ -795,7 +795,7 @@ final class ArcanistBundle extends Phobject { $new_data = $this->getBlob($new_phid, $name); } - $new_length = strlen($new_data); + $new_length = phutil_nonempty_string($new_data) ? strlen($new_data) : 0; $this->reserveBytes($new_length * 5 / 4); if ($new_data === null) {