summaryrefslogtreecommitdiffstats
path: root/src/H5FDstdio.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2013-02-27 19:22:27 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2013-02-27 19:22:27 (GMT)
commitb2f2370b1f26b8864c70f7ccc8cc023260ca99a0 (patch)
treef9bc7e59d6e48d5de16c21f48b214489d58725b3 /src/H5FDstdio.c
parente8fa6193f5ae4713f2ca9ff02965951c9d97016b (diff)
downloadhdf5-b2f2370b1f26b8864c70f7ccc8cc023260ca99a0.zip
hdf5-b2f2370b1f26b8864c70f7ccc8cc023260ca99a0.tar.gz
hdf5-b2f2370b1f26b8864c70f7ccc8cc023260ca99a0.tar.bz2
[svn-r23321] Description:
Merge r23313 from trunk to 1.8 branch: Bring changes from Coverity branch to the trunk: r20612: Changed string functions to versions with string length to fix coverity issues 922, 942 and 943. r20614: Use HDsnprintf. --gh r20675: Fix for coverity #1714 due to the fix for #810. Use HDfree() instead of H5MM_xfree(). r20678: Repaired coverity issue #598 -- failure to check return value from a call to fstat(), or to tidy up in the event of failure. r20679: Use HDstrncpy. --gh r20681: Use HDstrncat and HDstrncpy. --gh Tested on: Mac OSX/64 10.8.2 (amazon) w/debug, C++ & FORTRAN (too minor to require h5committest)
Diffstat (limited to 'src/H5FDstdio.c')
-rw-r--r--src/H5FDstdio.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c
index 0ef6744..9601cb0 100644
--- a/src/H5FDstdio.c
+++ b/src/H5FDstdio.c
@@ -413,23 +413,36 @@ H5FD_stdio_open( const char *name, unsigned flags, hid_t fapl_id,
/* Get the file descriptor (needed for truncate and some Windows information) */
file->fd = fileno(file->fp);
- if(file->fd < 0)
+ if(file->fd < 0) {
+ free(file);
+ fclose(f);
H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTOPENFILE, "unable to get file descriptor", NULL);
+ } /* end if */
#ifdef H5_HAVE_WIN32_API
file->hFile = (HANDLE)_get_osfhandle(file->fd);
- if(INVALID_HANDLE_VALUE == file->hFile)
+ if(INVALID_HANDLE_VALUE == file->hFile) {
+ free(file);
+ fclose(f);
H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTOPENFILE, "unable to get Windows file handle", NULL);
+ } /* end if */
- if(!GetFileInformationByHandle((HANDLE)file->hFile, &fileinfo))
- H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTOPENFILE, "unable to get Windows file desinformationcriptor", NULL);
+ if(!GetFileInformationByHandle((HANDLE)file->hFile, &fileinfo)) {
+ free(file);
+ fclose(f);
+ H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_CANTOPENFILE, "unable to get Windows file descriptor information", NULL);
+ } /* end if */
file->nFileIndexHigh = fileinfo.nFileIndexHigh;
file->nFileIndexLow = fileinfo.nFileIndexLow;
file->dwVolumeSerialNumber = fileinfo.dwVolumeSerialNumber;
#else /* H5_HAVE_WIN32_API */
- fstat(file->fd, &sb);
+ if(fstat(file->fd, &sb) < 0) {
+ free(file);
+ fclose(f);
+ H5Epush_ret(func, H5E_ERR_CLS, H5E_FILE, H5E_BADFILE, "unable to fstat file", NULL)
+ } /* end if */
file->device = sb.st_dev;
#ifdef H5_VMS
file->inode[0] = sb.st_ino[0];