Skip to content

Commit 3a812d6

Browse files
committed
Conditionally assign only
1 parent a5a103f commit 3a812d6

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/Npgsql/Internal/Converters/ArrayConverterCore.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,12 @@ public Size GetSize(SizeContext context, object values, ref object? writeState)
113113
Metadata = metadata,
114114
IterationIndices = indices
115115
};
116-
result.ArrayPool = arrayPool;
117-
result.Data = elemData!;
118-
result.AnyWriteState = anyWriteState;
116+
if (elemData is not null)
117+
{
118+
result.ArrayPool = arrayPool;
119+
result.Data = new(elemData, 0, metadata.TotalElements);
120+
result.AnyWriteState = anyWriteState;
121+
}
119122
result.FixedSizeElements = fixedSizeElements;
120123
writeState = result;
121124
return size;

0 commit comments

Comments
 (0)