summaryrefslogtreecommitdiffstats
path: root/src/H5FD.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5FD.c')
-rw-r--r--src/H5FD.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/H5FD.c b/src/H5FD.c
index c2f893f..9262323 100644
--- a/src/H5FD.c
+++ b/src/H5FD.c
@@ -2035,7 +2035,10 @@ H5FD_read(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t siz
unsigned char *read_buf=(unsigned char *)buf; /* Pointer to the buffer being read in */
size_t amount_read; /* Amount to read at a time */
- haddr_t read_off; /* Offset to read from */
+#ifndef NDEBUG
+ hsize_t tempamount_read; /* Amount to read at a time */
+#endif /* NDEBUG */
+ hsize_t read_off; /* Offset to read from */
/* Double check that we aren't reading raw data */
assert(type!=H5FD_MEM_DRAW);
@@ -2043,7 +2046,7 @@ H5FD_read(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t siz
/* Read the part before the metadata accumulator */
if(addr<file->accum_loc) {
/* Set the amount to read */
- amount_read=file->accum_loc-addr;
+ H5_ASSIGN_OVERFLOW(amount_read,file->accum_loc-addr,hsize_t,size_t);
/* Dispatch to driver */
if ((file->cls->read)(file, type, dxpl_id, addr, amount_read, read_buf)<0)
@@ -2061,7 +2064,13 @@ H5FD_read(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t siz
read_off=addr-file->accum_loc;
/* Set the amount to "read" */
- amount_read=MIN((file->accum_size-read_off),size);
+#ifndef NDEBUG
+ tempamount_read = file->accum_size-read_off;
+ H5_CHECK_OVERFLOW(tempamount_read,hsize_t,size_t);
+ amount_read = MIN(size, (size_t)tempamount_read);
+#else /* NDEBUG */
+ amount_read = MIN(size, (size_t)tempamount_read);
+#endif /* NDEBUG */
/* Copy the data out of the buffer */
HDmemcpy(read_buf,file->meta_accum+read_off,amount_read);
@@ -2249,7 +2258,7 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t si
/* Check if the new metadata overlaps the beginning of the current accumulator */
else if(addr<file->accum_loc && (addr+size)<=(file->accum_loc+file->accum_size)) {
/* Calculate the new accumulator size, based on the amount of overlap */
- new_size=(file->accum_loc-addr)+file->accum_size;
+ H5_ASSIGN_OVERFLOW(new_size,(file->accum_loc-addr)+file->accum_size,hsize_t,size_t);
/* Check if we need more buffer space */
if(new_size>file->accum_buf_size) {
@@ -2262,7 +2271,7 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t si
} /* end if */
/* Calculate the proper offset of the existing metadata */
- old_offset=(addr+size)-file->accum_loc;
+ H5_ASSIGN_OVERFLOW(old_offset,(addr+size)-file->accum_loc,hsize_t,size_t);
/* Move the existing metadata to the proper location */
HDmemmove(file->meta_accum+size,file->meta_accum+old_offset,(file->accum_size-old_offset));
@@ -2280,7 +2289,7 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t si
/* Check if the new metadata overlaps the end of the current accumulator */
else if(addr>=file->accum_loc && (addr+size)>(file->accum_loc+file->accum_size)) {
/* Calculate the new accumulator size, based on the amount of overlap */
- new_size=(addr-file->accum_loc)+size;
+ H5_ASSIGN_OVERFLOW(new_size,(addr-file->accum_loc)+size,hsize_t,size_t);
/* Check if we need more buffer space */
if(new_size>file->accum_buf_size) {