diff options
author | Sven Gothel <[email protected]> | 2023-02-12 00:21:38 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-02-12 00:21:38 +0100 |
commit | 0d10cb9976e243cfc2915677649dde5ad26de734 (patch) | |
tree | 5ca6e56398cf11121af620789c87b80bae0aca1b | |
parent | 38143d23daae59f3749fbc8793459a1ae572c173 (diff) |
NameTable: Check bounds on getRecord(int), re-add safe getRecordsRecordString(int)
-rw-r--r-- | src/main/java/net/java/dev/typecast/ot/table/NameTable.java | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/main/java/net/java/dev/typecast/ot/table/NameTable.java b/src/main/java/net/java/dev/typecast/ot/table/NameTable.java index 617e8c2..6630493 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/NameTable.java +++ b/src/main/java/net/java/dev/typecast/ot/table/NameTable.java @@ -97,12 +97,24 @@ public class NameTable implements Table { return _numberOfNameRecords; } - public NameRecord getRecord(int i) { - return _records[i]; + + public NameRecord getRecord(final int i) { + if(_numberOfNameRecords > i) { + return _records[i]; + } + return null; } + public String getRecordsRecordString(final int i) { + if(_numberOfNameRecords > i) { + return _records[i].getRecordString(); + } else { + return ""; + } + } + + /** Return a named record string */ public String getRecordString(short nameId) { - // Search for the first instance of this name ID for (int i = 0; i < _numberOfNameRecords; i++) { if (_records[i].getNameId() == nameId) { |