Skip to content

Commit 6d9a552

Browse files
committed
Avoid invalid array access
1 parent 0d6a707 commit 6d9a552

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/Adoy/FastCGI/Client.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -538,9 +538,7 @@ public function wait_for_response($requestId, $timeoutMs = 0) {
538538
// but still not get the response requested
539539
$startTime = microtime(true);
540540

541-
do {
542-
$resp = $this->readPacket();
543-
541+
while ($resp = $this->readPacket()) {
544542
if ($resp['type'] == self::STDOUT || $resp['type'] == self::STDERR) {
545543
if ($resp['type'] == self::STDERR) {
546544
$this->_requests[$resp['requestId']]['state'] = self::REQ_STATE_ERR;
@@ -549,7 +547,7 @@ public function wait_for_response($requestId, $timeoutMs = 0) {
549547
}
550548
if ($resp['type'] == self::END_REQUEST) {
551549
$this->_requests[$resp['requestId']]['state'] = self::REQ_STATE_OK;
552-
if ($resp['requestId'] == $requestId) {
550+
if ($resp['requestId'] == $requestId) {
553551
break;
554552
}
555553
}
@@ -558,7 +556,7 @@ public function wait_for_response($requestId, $timeoutMs = 0) {
558556
$this->set_ms_timeout($this->_readWriteTimeout);
559557
throw new \Exception('Timed out');
560558
}
561-
} while ($resp);
559+
}
562560

563561
if (!is_array($resp)) {
564562
$info = stream_get_meta_data($this->_sock);

0 commit comments

Comments
 (0)