summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2012-02-07 15:49:44 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2012-02-07 15:49:44 (GMT)
commita7c969372e8bdc0e66f0e15f204185360bb0e60b (patch)
tree75aeb08891459b2603319d242afe16c70a3565da /src
parent4596ad79a992308e4cc0a6e4a6493fe48bd3bf8b (diff)
downloadhdf5-a7c969372e8bdc0e66f0e15f204185360bb0e60b.zip
hdf5-a7c969372e8bdc0e66f0e15f204185360bb0e60b.tar.gz
hdf5-a7c969372e8bdc0e66f0e15f204185360bb0e60b.tar.bz2
[svn-r21912] Issue 7756 - Creating a dataset in a read-only file caused seg fault when the file is closed. I fixed the problem by putting a condition check early in H5O_create of H5O.c. The old code checked it too late, not until a file space is created. I added a test case in tfile.c to check the creation of group, dataset, attribute, and datatype.
Tested on jam - I've tested the same changes in the trunk with h5committest.
Diffstat (limited to 'src')
-rw-r--r--src/H5O.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/H5O.c b/src/H5O.c
index bc7a913..f113001 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -1121,10 +1121,12 @@ H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, size_t initial_rc,
/* check args */
HDassert(f);
- HDassert(H5F_INTENT(f) & H5F_ACC_RDWR);
HDassert(loc);
HDassert(TRUE == H5P_isa_class(ocpl_id, H5P_OBJECT_CREATE));
+ /* Check for invalid access request */
+ if(0 == (H5F_INTENT(f) & H5F_ACC_RDWR))
+ HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "no write intent on file")
/* Make certain we allocate at least a reasonable size for the object header */
size_hint = H5O_ALIGN_F(f, MAX(H5O_MIN_SIZE, size_hint));