Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
d50babfc
Commit
d50babfc
authored
Oct 02, 2019
by
andrey-golubev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
G-API: fix perform substitution UB/crash
parent
3133bb49
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
1 deletion
+10
-1
perform_substitution.cpp
modules/gapi/src/compiler/passes/perform_substitution.cpp
+10
-1
No files found.
modules/gapi/src/compiler/passes/perform_substitution.cpp
View file @
d50babfc
...
...
@@ -57,10 +57,19 @@ void performSubstitution(GModel::Graph& graph,
const
auto
&
patternDataNode
=
std
::
get
<
0
>
(
it
);
const
auto
&
substituteDataNode
=
std
::
get
<
1
>
(
it
);
const
auto
&
graphDataNode
=
patternToGraphMatch
.
outputDataNodes
.
at
(
patternDataNode
);
// delete existing edges (otherwise we cannot redirect)
for
(
auto
e
:
graphDataNode
->
inEdges
())
{
auto
existingEdges
=
graphDataNode
->
inEdges
();
// NB: we cannot iterate over node->inEdges() here directly because it gets modified when
// edges are erased. Erasing an edge supposes that src/dst nodes will remove
// (correspondingly) out/in edge (which is _our edge_). Now, this deleting means
// node->inEdges() will also get updated in the process: so, we'd iterate over a
// container which changes in this case. Using supplementary std::vector instead:
std
::
vector
<
ade
::
EdgeHandle
>
handles
(
existingEdges
.
begin
(),
existingEdges
.
end
());
for
(
const
auto
&
e
:
handles
)
{
graph
.
erase
(
e
);
}
GModel
::
redirectWriter
(
graph
,
substituteDataNode
,
graphDataNode
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment