Incorrect handling of filename in ScriptWindow::saveHDF5
Status: Beta
Brought to you by:
abalakin
The following code in scriptwindow.cpp is incorrect:
const char *fname = fileName.toAscii().constData();
H5Eset_auto(0,0);
hf = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
because QByteArray object created by fileName.toAscii is temporary and is destroyed after constData call. So pointer fname will point to unallocated memory region.
This behavior leads to the following problem: after 'saving as' new HDF5 file data are written to file with incorrect and spurious name.
The following fix is proposed:
QByteArray barray = fileName.toAscii();
const char *fname = barray.constData();
The discussion in Russian is here:
http://www.linux.org.ru/forum/development/5610360
http://www.linux.org.ru/forum/development/5612770