From cbd1e3c2af8045f736b13bd1721986363fcad045 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sat, 5 Jun 2021 12:51:23 +0200 Subject: [PATCH] Fix undefined index access when using "@php " in script handler, fixes #9943 --- src/Composer/EventDispatcher/EventDispatcher.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Composer/EventDispatcher/EventDispatcher.php b/src/Composer/EventDispatcher/EventDispatcher.php index 5a06314d8..ea4493432 100644 --- a/src/Composer/EventDispatcher/EventDispatcher.php +++ b/src/Composer/EventDispatcher/EventDispatcher.php @@ -265,8 +265,8 @@ class EventDispatcher } // match somename (not in quote, and not a qualified path) and if it is not a valid path from CWD then try to find it // in $PATH. This allows support for `@php foo` where foo is a binary name found in PATH but not an actual relative path - preg_match('{^[^\'"\s/\\\\]+}', $pathAndArgs, $match); - if (!file_exists($match[0])) { + $matched = preg_match('{^[^\'"\s/\\\\]+}', $pathAndArgs, $match); + if ($matched && !file_exists($match[0])) { $finder = new ExecutableFinder; if ($pathToExec = $finder->find($match[0])) { $pathAndArgs = $pathToExec . substr($pathAndArgs, strlen($match[0]));