Skip to content

Commit

Permalink
fix index out of range during rowparser column reading
Browse files Browse the repository at this point in the history
  • Loading branch information
NotAdam committed Dec 8, 2021
1 parent 86193c4 commit d0b281f
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/Lumina/Excel/RowParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,14 @@ private byte GetBitPosition( byte flag )
/// </summary>
/// <param name="column">The column index to lookup</param>
/// <typeparam name="T">The type to store the read data in</typeparam>
/// <returns>The read data contained in the provided type</returns>
/// <returns>The read data contained in the provided type, or the default value of the type if the column given is out of bounds</returns>
public T? ReadColumn< T >( int column )
{
if( column >= _sheet.ColumnCount )
{
return default;
}

var col = _sheet.Columns[ column ];

Stream.Position = _rowOffset + col.Offset;
Expand All @@ -453,9 +458,14 @@ private byte GetBitPosition( byte flag )
/// but this can be useful when you don't need to care about it's type and can use it as is - e.g. ToString and so on
/// </remarks>
/// <param name="column">The column index to read from</param>
/// <returns>An object containing the data from the row.</returns>
public object ReadColumnRaw( int column )
/// <returns>An object containing the data from the row, or null if the column given is out of bounds</returns>
public object? ReadColumnRaw( int column )
{
if( column >= _sheet.ColumnCount )
{
return null;
}

var col = _sheet.Columns[ column ];

Stream.Position = _rowOffset + col.Offset;
Expand Down

0 comments on commit d0b281f

Please sign in to comment.