Commit c55122c8 authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Fix implicit conversion in streamReadVarSlice and streamReadVarSliceF.

parent 38fe859a
......@@ -1671,7 +1671,7 @@ void streamReadVarSlice(int streamID, int varID, int levelID, double *data, int
if ( cdiStreamReadVarSlice(streamID, varID, levelID, MEMTYPE_DOUBLE, data, nmiss) )
{
Warning("Unexpected error returned from cdiStreamReadVarSlice()!");
size_t elementCount = gridInqSize(vlistInqVarGrid(streamInqVlist(streamID), varID));
size_t elementCount = (size_t)gridInqSize(vlistInqVarGrid(streamInqVlist(streamID), varID));
memset(data, 0, elementCount * sizeof(*data));
}
}
......@@ -1700,10 +1700,10 @@ void streamReadVarSliceF(int streamID, int varID, int levelID, float *data, int
{
// In case the file format does not support single precision reading,
// we fall back to double precision reading, converting the data on the fly.
size_t elementCount = gridInqSize(vlistInqVarGrid(streamInqVlist(streamID), varID));
size_t elementCount = (size_t)gridInqSize(vlistInqVarGrid(streamInqVlist(streamID), varID));
double* conversionBuffer = malloc(elementCount * sizeof(*conversionBuffer));
streamReadVarSlice(streamID, varID, levelID, conversionBuffer, nmiss);
for (size_t i = elementCount; i--; ) data[i] = conversionBuffer[i];
for (size_t i = elementCount; i--; ) data[i] = (float)conversionBuffer[i];
free(conversionBuffer);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment