memcpy: Check sizeof double and long

This commit is contained in:
Shahram Najm 2020-08-05 17:59:15 +01:00
parent c39585dc93
commit 744c305e4e
1 changed files with 4 additions and 4 deletions

View File

@ -442,22 +442,22 @@ unsigned long grib_ieee_to_long(double x)
* Byte swapping is actually implemented in grib_decode_unsigned_long and
* grib_encode_unsigned_long.
*/
unsigned long grib_ieee64_to_long(double x)
{
unsigned long lval;
memcpy(&lval, &x, 8);
DebugAssert(sizeof(double) == sizeof(long));
memcpy(&lval, &x, sizeof(long));
return lval;
}
double grib_long_to_ieee64(unsigned long x)
{
double dval;
memcpy(&dval, &x, 8);
DebugAssert(sizeof(double) == sizeof(long));
memcpy(&dval, &x, sizeof(long));
return dval;
}
int grib_ieee_decode_array(grib_context* c, unsigned char* buf, size_t nvals, int bytes, double* val)
{
int err = 0, i = 0, j = 0;