hdf5: fix crashes on extraction of compound fields integer 64 bits ( signed and 31/19731/2
Antoine ELIAS [Thu, 8 Feb 2018 14:29:25 +0000 (15:29 +0100)]
unsigned )

fix free exception in H5CompoundData.
Can be really fix with hdf5 >= 1.8.16 (h5free_memory)

Change-Id: I70069cc75504aa38ef79c40ddc4cdd88bd7eb43c

scilab/CHANGES.md
scilab/modules/hdf5/src/cpp/H5CompoundData.cpp
scilab/modules/hdf5/src/cpp/H5DataFactory.cpp

index 376db57..5b1e4db 100644 (file)
@@ -517,6 +517,7 @@ Known issues
 * [#15370](http://bugzilla.scilab.org/show_bug.cgi?id=15370): `bezout()` mishandled its output arguments.
 * [#15375](http://bugzilla.scilab.org/show_bug.cgi?id=15375): A .zcos file opened as a palette was greyed out.
 * [#15395](http://bugzilla.scilab.org/show_bug.cgi?id=15395): `ones(2,3,2) / %z` yielded an error..
+* [#15405](http://bugzilla.scilab.org/show_bug.cgi?id=15405): Accessing int64 hdf5 values crashed scilab.
 
 
 ### Bugs fixed in 6.0.0:
index 32fbef3..89ead83 100644 (file)
@@ -30,6 +30,11 @@ H5CompoundData::H5CompoundData(H5Object & _parent, const hsize_t _totalSize, con
         hid_t mtype = H5Tget_member_type(compoundType, i);
         hsize_t size = H5Tget_size(mtype);
         char * mname = H5Tget_member_name(compoundType, i);
+        std::string name(mname);
+
+        //free crash: it will be fix with hdf5 libs >= 1.8.16 with new function h5free_memory
+        //h5free_memory(mname);
+
         size_t offs = H5Tget_member_offset(compoundType, i);
         FieldInfo * info = 0;
         if (H5Tget_class(type) == H5T_STRING && !H5Tis_variable_str(type))
@@ -38,10 +43,9 @@ H5CompoundData::H5CompoundData(H5Object & _parent, const hsize_t _totalSize, con
             size++;
         }
 
-        info = new FieldInfo(mtype, size, offs, std::string(mname));
-        (*infos)[std::string(mname)] = info;
+        info = new FieldInfo(mtype, size, offs, name);
+        (*infos)[name] = info;
         fieldinfos[i] = info;
-        free(mname);
     }
 }
 
index 14dfbe5..8f1f9da 100644 (file)
@@ -91,11 +91,11 @@ H5Data & H5DataFactory::getObjectData(H5Object & parent, const hsize_t totalSize
 
 #ifdef __SCILAB_INT64__
 
-            else if (H5Tequal(type, H5T_NATIVE_LONG))
+            else if (H5Tequal(type, H5T_NATIVE_LLONG))
             {
                 return *new H5BasicData<long long>(parent, totalSize, dataSize, ndims, dims, (long long *)data, stride, offset, dataOwner);
             }
-            else if (H5Tequal(type, H5T_NATIVE_ULONG))
+            else if (H5Tequal(type, H5T_NATIVE_ULLONG))
             {
                 return *new H5BasicData<unsigned long long>(parent, totalSize, dataSize, ndims, dims, (unsigned long long *)data, stride, offset, dataOwner);
             }