summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Harten <pharten@ncsa.uiuc.edu>1999-02-01 22:56:27 (GMT)
committerPaul Harten <pharten@ncsa.uiuc.edu>1999-02-01 22:56:27 (GMT)
commit4fc2c5fb596e4233295fad8d66dd963525780a1f (patch)
tree7526083b6088b6be2f3502c5b7b7c24991d099e2
parent3dae05f72ddd7a4e1eb6cd7dd4566583f8c7032d (diff)
downloadhdf5-4fc2c5fb596e4233295fad8d66dd963525780a1f.zip
hdf5-4fc2c5fb596e4233295fad8d66dd963525780a1f.tar.gz
hdf5-4fc2c5fb596e4233295fad8d66dd963525780a1f.tar.bz2
[svn-r1043] Purpose:
Bug fix Problem: Depending on how the string size changes, different buffers are used when copying from one array of strings to another array of strings. An ASSERTION() is set up to check the validity of the buffer being used for each element of the string array being copied. This ASSERTION() fails for a 10 element string array of string length 42 being copied to a 10 element string array of string length 50. Solution: The overlap variable (olap) is calculated slightly differently. Also, since olap and nelmts are unsigned types, the conditional assignment: d = elmtno >= nelmts-olap ? dbuf : dp should be rewitten as: d = elmtno+olap >= nelmts ? dbuf : dp This same problem/solution may exist in H5T_conv_i_i(), and H5T_conv_f_f(). Platform tested: Solaris2.5
-rw-r--r--src/H5Tconv.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/H5Tconv.c b/src/H5Tconv.c
index 4915b22..86ccea3 100644
--- a/src/H5Tconv.c
+++ b/src/H5Tconv.c
@@ -2003,14 +2003,12 @@ H5T_conv_s_s (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
} else if (src->size>=dst->size) {
sp = dp = (uint8_t*)buf;
direction = 1;
- olap = (size_t)(HDceil((double)(src->size)/
- (double)(src->size-dst->size))-1);
+ olap = HDceil((double)(dst->size)/(double)(src->size-dst->size));
} else {
sp = (uint8_t*)buf + (nelmts-1) * src->size;
dp = (uint8_t*)buf + (nelmts-1) * dst->size;
direction = -1;
- olap = (size_t)(HDceil((double)(dst->size)/
- (double)(dst->size-src->size))-1);
+ olap = HDceil((double)(src->size)/(double)(dst->size-src->size));
}
/* Allocate the overlap buffer */
@@ -2031,7 +2029,7 @@ H5T_conv_s_s (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
d = elmtno<olap ? dbuf : dp;
} else {
s = sp;
- d = elmtno >= nelmts-olap ? dbuf : dp;
+ d = elmtno+olap >= nelmts ? dbuf : dp;
}
#ifndef NDEBUG
/* I don't quite trust the overlap calculations yet --rpm */