mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-01-30 15:32:37 +08:00
[svn-r9865] Purpose:
Bug fix Description: Catch another way that vsnprintf() can fail (this time on the HP) and deal with that. Platforms tested: HP/UX 11.x (kelgia) Doesn't affect other platforms
This commit is contained in:
parent
68e5b3e014
commit
24c134e28b
4
configure
vendored
4
configure
vendored
@ -31003,7 +31003,7 @@ if test `eval echo '${'$as_ac_var'}'` = yes; then
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
|
||||
_ACEOF
|
||||
echo "$as_me:$LINENO: checking if vsnprintf returns correct value" >&5
|
||||
echo "$as_me:$LINENO: checking if vsnprintf returns correct value" >&5
|
||||
echo $ECHO_N "checking if vsnprintf returns correct value... $ECHO_C" >&6
|
||||
|
||||
if test "${hdf5_cv_vsnprintf_works+set}" = set; then
|
||||
@ -31032,7 +31032,7 @@ int test_vsnprintf(const char *fmt,...)
|
||||
ret=vsnprintf(s,16,"%s",ap);
|
||||
va_end(ap);
|
||||
|
||||
return(ret==15 ? 1 : 0);
|
||||
return(ret!=42 ? 1 : 0);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
|
12
configure.in
12
configure.in
@ -1653,7 +1653,15 @@ AC_CHECK_FUNCS(vsnprintf,
|
||||
|
||||
dnl Check if vsnprintf() returns correct size for strings that don't fit
|
||||
dnl into the size allowed. If vsnprintf() works correctly on this platform,
|
||||
dnl it should return a value larger than 15 for the test below
|
||||
dnl it should return a value of 42 for the test below
|
||||
dnl
|
||||
dnl Note that vsnprintf fails in two different ways:
|
||||
dnl - In IRIX64, calls to vnsprintf() with a formatted string that
|
||||
dnl is larger than the buffer size allowed incorrectly
|
||||
dnl return the size of the buffer minus one.
|
||||
dnl - In HP/UX, calls to vsnprintf() with a formatted string that
|
||||
dnl is larger than the buffer size allowed incorrectly
|
||||
dnl return (-1)
|
||||
AC_MSG_CHECKING([if vsnprintf returns correct value])
|
||||
|
||||
AC_CACHE_VAL([hdf5_cv_vsnprintf_works],
|
||||
@ -1672,7 +1680,7 @@ int test_vsnprintf(const char *fmt,...)
|
||||
ret=vsnprintf(s,16,"%s",ap);
|
||||
va_end(ap);
|
||||
|
||||
return(ret==15 ? 1 : 0);
|
||||
return(ret!=42 ? 1 : 0);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
|
14
src/H5E.c
14
src/H5E.c
@ -1384,7 +1384,7 @@ done:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t
|
||||
static herr_t
|
||||
H5E_pop(H5E_t *estack, size_t count)
|
||||
{
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
@ -1526,11 +1526,15 @@ H5Epush_stack(hid_t err_stack, const char *file, const char *func, unsigned line
|
||||
/* If the description doesn't fit into the initial buffer size, allocate more space and try again */
|
||||
while((desc_len=HDvsnprintf(tmp, (size_t)tmp_len, fmt, ap))
|
||||
#ifdef H5_VSNPRINTF_WORKS
|
||||
>
|
||||
>
|
||||
#else /* H5_VSNPRINTF_WORKS */
|
||||
>=
|
||||
>=
|
||||
#endif /* H5_VSNPRINTF_WORKS */
|
||||
(tmp_len-1)) {
|
||||
(tmp_len-1)
|
||||
#ifndef H5_VSNPRINTF_WORKS
|
||||
|| desc_len<0
|
||||
#endif /* H5_VSNPRINTF_WORKS */
|
||||
) {
|
||||
/* shutdown & restart the va_list */
|
||||
va_end(ap);
|
||||
va_start(ap, fmt);
|
||||
@ -1542,7 +1546,7 @@ H5Epush_stack(hid_t err_stack, const char *file, const char *func, unsigned line
|
||||
#ifdef H5_VSNPRINTF_WORKS
|
||||
tmp_len = desc_len+1;
|
||||
#else /* H5_VSNPRINTF_WORKS */
|
||||
tmp_len = 2 * desc_len;
|
||||
tmp_len = 2 * tmp_len;
|
||||
#endif /* H5_VSNPRINTF_WORKS */
|
||||
if((tmp=H5MM_malloc((size_t)tmp_len))==NULL)
|
||||
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
|
||||
|
Loading…
Reference in New Issue
Block a user