1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-29 20:28:59 +01:00

Prevent infinite loop while scanning in some situations

This commit is contained in:
Matt Brown 2021-01-26 15:51:15 -05:00 committed by Daniil Gentili
parent 4627065d1f
commit 43170a84a9
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7

View File

@ -222,7 +222,7 @@ class TaintFlowGraph extends DataFlowGraph
/**
* @param array<string> $source_taints
* @param array<DataFlowNode> $sinks
* @return list<DataFlowNode>
* @return array<string, DataFlowNode>
*/
private function getChildNodes(
DataFlowNode $generated_source,
@ -245,6 +245,8 @@ class TaintFlowGraph extends DataFlowGraph
continue;
}
$destination_node = $this->nodes[$to_id];
$new_taints = \array_unique(
\array_diff(
\array_merge($source_taints, $added_taints),
@ -254,8 +256,6 @@ class TaintFlowGraph extends DataFlowGraph
\sort($new_taints);
$destination_node = $this->nodes[$to_id];
if (isset($visited_source_ids[$to_id][implode(',', $new_taints)])) {
continue;
}
@ -441,7 +441,8 @@ class TaintFlowGraph extends DataFlowGraph
$new_destination->specialized_calls = $generated_source->specialized_calls;
$new_destination->path_types = array_merge($generated_source->path_types, [$path_type]);
$new_sources[] = $new_destination;
$key = $to_id . ' ' . \json_encode($new_destination->specialized_calls);
$new_sources[$key] = $new_destination;
}
return $new_sources;