Skip to content

Commit a648b05

Browse files
committed
Fix NPE in serialization when the definition has no method (might be the case for UI sources)
1 parent 749426b commit a648b05

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

soot-infoflow/src/soot/jimple/infoflow/results/xml/InfoflowResultsSerializer.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import soot.jimple.infoflow.InfoflowConfiguration;
1313
import soot.jimple.infoflow.data.AccessPath;
1414
import soot.jimple.infoflow.data.AccessPathFragment;
15+
import soot.jimple.infoflow.data.SootMethodAndClass;
1516
import soot.jimple.infoflow.results.InfoflowPerformanceData;
1617
import soot.jimple.infoflow.results.InfoflowResults;
1718
import soot.jimple.infoflow.results.ResultSinkInfo;
@@ -209,7 +210,8 @@ private void writeSourceInfo(ResultSourceInfo source, XMLStreamWriter writer) th
209210
ISourceSinkDefinition def = source.getDefinition();
210211
if (def instanceof MethodSourceSinkDefinition) {
211212
MethodSourceSinkDefinition ms = (MethodSourceSinkDefinition) def;
212-
writer.writeAttribute(XmlConstants.Attributes.methodSourceSinkDefinition, ms.getMethod().getSignature());
213+
if (ms.getMethod() != null)
214+
writer.writeAttribute(XmlConstants.Attributes.methodSourceSinkDefinition, ms.getMethod().getSignature());
213215
}
214216

215217
writeAdditionalSourceInfo(source, writer);
@@ -271,7 +273,8 @@ private void writeSinkInfo(ResultSinkInfo sink, XMLStreamWriter writer) throws X
271273
ISourceSinkDefinition def = sink.getDefinition();
272274
if (def instanceof MethodSourceSinkDefinition) {
273275
MethodSourceSinkDefinition ms = (MethodSourceSinkDefinition) def;
274-
writer.writeAttribute(XmlConstants.Attributes.methodSourceSinkDefinition, ms.getMethod().getSignature());
276+
if (ms.getMethod() != null)
277+
writer.writeAttribute(XmlConstants.Attributes.methodSourceSinkDefinition, ms.getMethod().getSignature());
275278
}
276279
writeAdditionalSinkInfo(sink, writer);
277280
writeAccessPath(sink.getAccessPath(), writer);

0 commit comments

Comments
 (0)