Merge pull request #171 from Francessco121/bug/unicode-string-crash

Fix assembler crash when invalid Unicode string escape sequences are used
This commit is contained in:
Simon Fortier 2018-08-30 17:24:32 -04:00 committed by GitHub
commit a1cf279b6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

4
.gitignore vendored
View File

@ -17,4 +17,6 @@ Server/Server.iml
Server/src/main/java/META-INF/MANIFEST.MF
.settings
.project
.classpath
.classpath
# VSCode Workspace
.vscode/

View File

@ -156,7 +156,14 @@ public class Assembler {
//Unescape the string
String string = value.substring(1, value.length() - 1);
string = StringEscapeUtils.unescapeJava(string);
try {
string = StringEscapeUtils.unescapeJava(string);
} catch (IllegalArgumentException e) {
throw new InvalidOperandException(
"Invalid string operand \"" + string + "\": " + e.getMessage(),
currentLine);
}
out.write(string.getBytes(StandardCharsets.UTF_16BE));
} else if (labels != null && labels.containsKey(value)) {