[MOAB-dev] r3358 - MOAB/trunk/mhdf/src
kraftche at cae.wisc.edu
kraftche at cae.wisc.edu
Tue Nov 17 10:47:01 CST 2009
Author: kraftche
Date: 2009-11-17 10:47:01 -0600 (Tue, 17 Nov 2009)
New Revision: 3358
Modified:
MOAB/trunk/mhdf/src/file-desc.c
Log:
fix memory corruption when reading h5m file containing many tags
Modified: MOAB/trunk/mhdf/src/file-desc.c
===================================================================
--- MOAB/trunk/mhdf/src/file-desc.c 2009-11-17 16:18:15 UTC (rev 3357)
+++ MOAB/trunk/mhdf/src/file-desc.c 2009-11-17 16:47:01 UTC (rev 3358)
@@ -28,8 +28,8 @@
{
void* result_ptr;
struct mhdf_FileDesc* const input_ptr = *data;
- unsigned char* const mem_ptr = (unsigned char*)input_ptr;
- size_t new_size;
+ unsigned char* mem_ptr = (unsigned char*)input_ptr;
+ size_t new_size, orig_size = input_ptr->offset - mem_ptr;
if (mem_ptr + input_ptr->total_size < input_ptr->offset + append_bytes) {
if (append_bytes < input_ptr->total_size)
@@ -42,10 +42,13 @@
if (*data != input_ptr)
mhdf_fixFileDesc( *data, input_ptr );
+
+ mem_ptr = (unsigned char*)(*data);
+ (*data)->offset = mem_ptr + orig_size;
}
- result_ptr = input_ptr->offset;
- input_ptr->offset += append_bytes;
+ result_ptr = (*data)->offset;
+ (*data)->offset += append_bytes;
return result_ptr;
}
More information about the moab-dev
mailing list