Eliminate null references when Dispose is called.
diff --git a/EPPlus/CellStore.cs b/EPPlus/CellStore.cs
index a4dd683..6536325 100644
--- a/EPPlus/CellStore.cs
+++ b/EPPlus/CellStore.cs
@@ -202,7 +202,9 @@
internal PageIndex[] _pages;
internal int PageCount;
- public void Dispose()
+ public void Dispose()
+ {
+ if (_pages != null)
{
for (int p = 0; p < PageCount; p++)
{
@@ -210,6 +212,7 @@
}
_pages = null;
}
+ }
}
internal class PageIndex : IndexBase, IDisposable
@@ -1431,11 +1434,14 @@
public void Dispose()
{
if(_values!=null) _values.Clear();
- for(var c=0;c<ColumnCount;c++)
+ if (_columnIndex != null)
{
- if (_columnIndex[c] != null)
+ for (var c = 0; c < ColumnCount; c++)
{
- ((IDisposable)_columnIndex[c]).Dispose();
+ if (_columnIndex[c] != null)
+ {
+ ((IDisposable)_columnIndex[c]).Dispose();
+ }
}
}
_values = null;