summaryrefslogtreecommitdiffstats
path: root/src/H5Ocache.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Ocache.c')
-rw-r--r--src/H5Ocache.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/H5Ocache.c b/src/H5Ocache.c
index 5e12fdc..c507a6a 100644
--- a/src/H5Ocache.c
+++ b/src/H5Ocache.c
@@ -312,9 +312,10 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1,
oh->mesg[mesgno].dirty = TRUE;
merged_null_msgs++;
} else {
- /* new message */
- if (oh->nmesgs >= nmesgs)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "corrupt object header - too many messages");
+ /* Check if we need to extend message table to hold the new message */
+ if(oh->nmesgs >= oh->alloc_nmesgs)
+ if(H5O_alloc_msgs(oh, (size_t)1) < 0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate more space for messages")
mesgno = oh->nmesgs++;
oh->mesg[mesgno].type = H5O_msg_class_g[id];
oh->mesg[mesgno].dirty = FALSE;
@@ -346,9 +347,23 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1,
if(merged_null_msgs)
oh->cache_info.is_dirty = TRUE;
+/* Don't check for the incorrect # of object header messages bug unless we've
+ * enabled strict format checking. This allows for older files, created with
+ * a version of the library that had a bug in tracking the correct # of header
+ * messages to be read in without the library fussing about things. -QAK
+ */
+#ifdef H5_STRICT_FORMAT_CHECKS
/* Sanity check for the correct # of messages in object header */
if((oh->nmesgs + skipped_msgs + merged_null_msgs) != nmesgs)
HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "corrupt object header - too few messages")
+#else /* H5_STRICT_FORMAT_CHECKS */
+ /* Check for incorrect # of messages in object header and if we have write
+ * access on the file, flag the object header as dirty, so it gets fixed.
+ */
+ if((oh->nmesgs + skipped_msgs + merged_null_msgs) != nmesgs &&
+ (H5F_get_intent(f) & H5F_ACC_RDWR))
+ oh->cache_info.is_dirty = TRUE;
+#endif /* H5_STRICT_FORMAT_CHECKS */
/* Set return value */
ret_value = oh;