Skip to content

Commit d1b1ae5

Browse files
author
Tuan Nguyen
committed
Fixed NullReferenceException error if there's no record returned in ForwardsOnlyDataReader.UpdateOutputParameters
1 parent b5d201b commit d1b1ae5

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

Npgsql/Npgsql/NpgsqlDataReader.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,12 @@ private void UpdateOutputParameters()
10911091
{
10921092
if (CurrentDescription != null)
10931093
{
1094-
NpgsqlRow row = null;
1094+
NpgsqlRow row = ParameterUpdateRow;
1095+
if (row == null)
1096+
{
1097+
return;
1098+
}
1099+
10951100
Queue<NpgsqlParameter> pending = new Queue<NpgsqlParameter>();
10961101
List<int> taken = new List<int>();
10971102
foreach (NpgsqlParameter p in _command.Parameters)
@@ -1105,16 +1110,12 @@ private void UpdateOutputParameters()
11051110
}
11061111
else
11071112
{
1108-
if ((row = row ?? ParameterUpdateRow) == null)
1109-
{
1110-
return;
1111-
}
11121113
p.Value = row[idx];
11131114
taken.Add(idx);
11141115
}
11151116
}
11161117
}
1117-
for (int i = 0; pending.Count != 0 && i != (row = row ?? ParameterUpdateRow).NumFields; ++i)
1118+
for (int i = 0; pending.Count != 0 && i != row.NumFields; ++i)
11181119
{
11191120
if (!taken.Contains(i))
11201121
{

0 commit comments

Comments
 (0)