Merge pull request #62 from ilgrosso/ARRAY_INDEX_OUT_OF_BOUNDS

Checking array size before access to avoid ArrayIndexOutOfBoundsException
This commit is contained in:
Francesco Chicchiriccò 2020-06-09 13:23:12 +02:00 committed by GitHub
commit 61ec81624d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -147,7 +147,7 @@ public class PrimaryRow
* Return the I/O information for the given set foreign key.
*/
public ColumnIO getForeignKeyIO(ForeignKey fk) {
return (_fkIO == null) ? null : _fkIO[fk.getIndex()];
return _fkIO == null ? null : _fkIO.length <= fk.getIndex() ? null : _fkIO[fk.getIndex()];
}
/**
@ -155,7 +155,7 @@ public class PrimaryRow
* constraint analyses are not recorded.
*/
public OpenJPAStateManager getForeignKeySet(ForeignKey fk) {
return (_fkSet == null) ? null : _fkSet[fk.getIndex()];
return _fkSet == null ? null : _fkSet.length <= fk.getIndex() ? null : _fkSet[fk.getIndex()];
}
/**
@ -163,7 +163,7 @@ public class PrimaryRow
* constraint analyses are not recorded.
*/
public OpenJPAStateManager getForeignKeyWhere(ForeignKey fk) {
return (_fkWhere == null) ? null : _fkWhere[fk.getIndex()];
return _fkWhere == null ? null : _fkWhere.length <= fk.getIndex() ? null : _fkWhere[fk.getIndex()];
}
@Override
@ -195,9 +195,9 @@ public class PrimaryRow
public void clearForeignKey(ForeignKey fk)
throws SQLException {
super.clearForeignKey(fk);
if (_fkSet != null)
if (_fkSet != null && _fkSet.length > fk.getIndex())
_fkSet[fk.getIndex()] = null;
if (_fkIO != null)
if (_fkIO != null && _fkIO.length > fk.getIndex())
_fkIO[fk.getIndex()] = null;
}