Skip to content

Commit

Permalink
Fixed critical paring bug when using MPD_CMD_READ_LIST_SINGLE - mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Flo Faber committed Dec 4, 2023
1 parent 25ac069 commit 181fc1a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Socket.php
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,11 @@ protected function parse(array $lines, int $mode = MPD_CMD_READ_NORMAL, array $l
$tmp[$k] = $v;
}

// set the first encountered key if there isn't already one
if(($mode === MPD_CMD_READ_LIST || $mode === MPD_CMD_READ_LIST_SINGLE || $mode === MPD_CMD_READ_GROUP) && $first_key === NULL){
$first_key = $k;
}

// omfg
// ok,ok. If we read a list and the `key` of the next line is either in `$list_starts` or is equal to `$first_key` we push the list-item to the list of items.
if($mode === MPD_CMD_READ_LIST &&
Expand All @@ -546,10 +551,7 @@ protected function parse(array $lines, int $mode = MPD_CMD_READ_NORMAL, array $l
$b[] = $v;
}

// set the first encountered key if there isn't already one
if(($mode === MPD_CMD_READ_LIST || $mode === MPD_CMD_READ_LIST_SINGLE || $mode === MPD_CMD_READ_GROUP) && $first_key === NULL){
$first_key = $k;
}


}

Expand Down

0 comments on commit 181fc1a

Please sign in to comment.