Bug 32795 - DoubleDataContainer DoCopyValue() can cause crash
Summary: DoubleDataContainer DoCopyValue() can cause crash
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Data (show other bugs)
Version: 4.0.0
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2015-08-05 09:07 UTC by Yi Zhenfei
Modified: 2015-08-05 09:07 UTC (History)
1 user (show)

See Also:
Is this bug a regression?: ---
Last known good build:


Description Yi Zhenfei 2015-08-05 09:07:26 UTC
in DataContainer.cs line 864		
protected override void DoCopyValue (DataContainer from, int from_index, int to_index)
    _values [to_index] = (double) GetContainerData (from.GetValue (from_index));

GetContainerData may return null, and casting it to double will cause a NullReferenceException.

I found this when I was trying to migrate my application from windows to linux. It works fine on windows(with official .NET runtime), but it will crash for this reason on linux.

The stacktrace:

System.NullReferenceException: Object reference not set to an instance of an object
  at System.Data.Common.DoubleDataContainer.DoCopyValue (System.Data.Common.DataContainer from, Int32 from_index, Int32 to_index) [0x00000] in /root/mono-4.0.2/mcs/class/System.Data/System.Data.Common/DataContainer.cs:866
  at System.Data.Common.DataContainer.CopyValue (System.Data.Common.DataContainer from, Int32 from_index, Int32 to_index) [0x00000] in /root/mono-4.0.2/mcs/class/System.Data/System.Data.Common/DataContainer.cs:237
  at System.Data.Common.RecordCache.CopyRecord (System.Data.DataTable fromTable, Int32 fromRecordIndex, Int32 toRecordIndex) [0x0004a] in /root/mono-4.0.2/mcs/class/System.Data/System.Data.Common/RecordCache.cs:112

The caller is ExcelDataReader, a third party library, so I cannot tell how it's using the class.

Note You need to log in before you can comment on or make changes to this bug.