diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2013-03-13 22:34:23 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2013-03-13 22:34:23 (GMT) |
commit | 08359be858ae9e4595dab1f4a7718017d9af7663 (patch) | |
tree | bbe033fd134cfda5943dff96ef2a7f5f10d743e9 /src/H5FDstdio.c | |
parent | 55822485c64197a6c2c4a623824fcdcd10a57d31 (diff) | |
download | hdf5-08359be858ae9e4595dab1f4a7718017d9af7663.zip hdf5-08359be858ae9e4595dab1f4a7718017d9af7663.tar.gz hdf5-08359be858ae9e4595dab1f4a7718017d9af7663.tar.bz2 |
[svn-r23347] ported revision 23248:23346 from the trunk
Diffstat (limited to 'src/H5FDstdio.c')
-rw-r--r-- | src/H5FDstdio.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c index 4e484c2..8f4f7f0 100644 --- a/src/H5FDstdio.c +++ b/src/H5FDstdio.c @@ -415,23 +415,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]; |