r248050 - Analyzer: Fix a crasher in UbigraphViz
Ismail Pazarbasi via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 18 14:54:47 PDT 2015
Author: ismailp
Date: Fri Sep 18 16:54:47 2015
New Revision: 248050
URL: http://llvm.org/viewvc/llvm-project?rev=248050&view=rev
Log:
Analyzer: Fix a crasher in UbigraphViz
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
Added:
cfe/trunk/test/Analysis/ubigraph-viz.cpp
Modified:
cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp?rev=248050&r1=248049&r2=248050&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp Fri Sep 18 16:54:47 2015
@@ -778,8 +778,9 @@ void UbigraphViz::AddEdge(ExplodedNode *
<< ", ('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'),"
Added: cfe/trunk/test/Analysis/ubigraph-viz.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/ubigraph-viz.cpp?rev=248050&view=auto
==============================================================================
--- cfe/trunk/test/Analysis/ubigraph-viz.cpp (added)
+++ cfe/trunk/test/Analysis/ubigraph-viz.cpp Fri Sep 18 16:54:47 2015
@@ -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;
+}
+
More information about the cfe-commits
mailing list