Fix potential NPEs in compiler and native runtime

This commit is contained in:
Alexey Andreev 2019-11-18 11:24:47 +03:00
parent 560627bfca
commit 631111bdb3
2 changed files with 17 additions and 15 deletions

View File

@ -131,7 +131,7 @@ public class BufferedCodeWriter extends CodeWriter {
return;
}
if (isNewLine) {
if (pendingFileName != null || pendingLineNumber >= 0) {
if (pendingFileName != null && pendingLineNumber >= 0) {
printLineDirective(pendingFileName, pendingLineNumber);
pendingLineNumber = -1;
pendingFileName = null;

View File

@ -55,21 +55,23 @@ public final class ExceptionHandling {
while (location != null) {
MethodLocation methodLocation = location.method;
Console.printString(" at ");
if (methodLocation.className == null || methodLocation.methodName == null) {
Console.printString("(Unknown method)");
} else {
Console.printString(methodLocation.className.value);
Console.printString(".");
Console.printString(methodLocation.methodName.value);
if (methodLocation != null) {
Console.printString(" at ");
if (methodLocation.className == null || methodLocation.methodName == null) {
Console.printString("(Unknown method)");
} else {
Console.printString(methodLocation.className.value);
Console.printString(".");
Console.printString(methodLocation.methodName.value);
}
Console.printString("(");
if (methodLocation.fileName != null && location.lineNumber >= 0) {
Console.printString(methodLocation.fileName.value);
Console.printString(":");
Console.printInt(location.lineNumber);
}
Console.printString(")\n");
}
Console.printString("(");
if (methodLocation.fileName != null && location.lineNumber >= 0) {
Console.printString(methodLocation.fileName.value);
Console.printString(":");
Console.printInt(location.lineNumber);
}
Console.printString(")\n");
location = location.next;
}