Skip to content

Commit

Permalink
Analyzer: Fix a crasher in UbigraphViz
Browse files Browse the repository at this point in the history
Summary:
Name `Out` refers to the parameter. It is moved into the member `Out`
in ctor-init. Dereferencing null pointer will crash clang, if user
passes '-analyzer-viz-egraph-ubigraph' argument.

Reviewers: zaks.anna, krememek

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D12119

llvm-svn: 248050
  • Loading branch information
ipazarbasi committed Sep 18, 2015
1 parent 9567495 commit d347e7a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
Expand Up @@ -778,8 +778,9 @@ void UbigraphViz::AddEdge(ExplodedNode *Src, ExplodedNode *Dst) {
<< ", ('arrow','true'), ('oriented', 'true'))\n";
}

UbigraphViz::UbigraphViz(std::unique_ptr<raw_ostream> Out, StringRef Filename)
: Out(std::move(Out)), Filename(Filename), Cntr(0) {
UbigraphViz::UbigraphViz(std::unique_ptr<raw_ostream> OutStream,
StringRef Filename)
: Out(std::move(OutStream)), Filename(Filename), Cntr(0) {

*Out << "('vertex_style_attribute', 0, ('shape', 'icosahedron'))\n";
*Out << "('vertex_style', 1, 0, ('shape', 'sphere'), ('color', '#ffcc66'),"
Expand Down
7 changes: 7 additions & 0 deletions clang/test/Analysis/ubigraph-viz.cpp
@@ -0,0 +1,7 @@
// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.API -analyzer-viz-egraph-ubigraph -verify %s
// expected-no-diagnostics

int f(int x) {
return x < 0 ? 0 : 42;
}

0 comments on commit d347e7a

Please sign in to comment.