Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ DataFlowType getErasedRepr(Type t) {
then result.(BoxedType).getPrimitiveType().getName() = "boolean"
else result = e
)
or
t instanceof NullType and result instanceof TypeObject
}

/** Gets a string representation of a type returned by `getErasedRepr`. */
Expand Down
9 changes: 9 additions & 0 deletions java/ql/test/library-tests/dataflow/null/A.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
public class A {
void sink(Object o) { }

void foo() {
Object src = null;
Object x = src;
sink(x);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
| A.java:5:18:5:21 | null | A.java:2:13:2:20 | o |
| A.java:5:18:5:21 | null | A.java:5:18:5:21 | null |
| A.java:5:18:5:21 | null | A.java:6:16:6:18 | src |
| A.java:5:18:5:21 | null | A.java:7:10:7:10 | x |
14 changes: 14 additions & 0 deletions java/ql/test/library-tests/dataflow/null/testnullflow.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import java
import semmle.code.java.dataflow.DataFlow

class Conf extends DataFlow::Configuration {
Conf() { this = "qqconf" }

override predicate isSource(DataFlow::Node n) { n.asExpr() instanceof NullLiteral }

override predicate isSink(DataFlow::Node n) { any() }
}

from Conf conf, DataFlow::Node src, DataFlow::Node sink
where conf.hasFlow(src, sink)
select src, sink