Skip to content

Commit

Permalink
Fix stack overflow
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@17019 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Sep 2, 2013
1 parent e8fc3c4 commit 4d37e18
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions Compiler/FrontEnd/ConnectUtil.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2222,7 +2222,7 @@ algorithm
// Add the connections to the graph.
graph := List.fold(inConnections, addConnectionToGraph, graph);
// Add the connections to the array with help from the graph.
outSets := setArrayAddConnections2(1, graph, inSets);
outSets := setArrayAddConnections2(1 <= arrayLength(graph), 1, graph, inSets);
end setArrayAddConnections;

protected function addConnectionToGraph
Expand All @@ -2243,34 +2243,26 @@ end addConnectionToGraph;

protected function setArrayAddConnections2
"Adds pointers to the set array."
input Boolean stop;
input Integer inIndex;
input SetGraph inGraph;
input array<Set> inSets;
output array<Set> outSets;
algorithm
outSets := matchcontinue(inIndex, inGraph, inSets)
outSets := match (stop, inIndex, inGraph, inSets)
local
list<Integer> edges;
array<Set> sets;
SetGraph graph;

case (_, _, _)
equation
true = inIndex > arrayLength(inGraph);
then
inSets;

case (_, _, _)
case (false, _, _, _) then inSets;
else
equation
(edges as _ :: _) = arrayGet(inGraph, inIndex);
edges = arrayGet(inGraph, inIndex);
(sets, graph) = setArrayAddConnection(inIndex, edges, inSets, inGraph);
then
setArrayAddConnections2(inIndex + 1, graph, sets);

else
setArrayAddConnections2(inIndex + 1, inGraph, inSets);
then setArrayAddConnections2(inIndex+1 <= arrayLength(graph), inIndex + 1, graph, sets);

end matchcontinue;
end match;
end setArrayAddConnections2;

protected function setArrayAddConnection
Expand Down

0 comments on commit 4d37e18

Please sign in to comment.