On some Windows 8 and Windows 10 machines we are experiencing strange heap corruption errors that cannot be reproduced with the debugger; running it in release mode from visual studio does not help either.
It does not happen on all Win8/10 machines, but I would say eight out of ten do crash with this heap corruption error.
By inserting some ::OutputDebugString methods i could trace down the problem to the DcmFileFormat::saveFile function.
I tried to step deeper into the dcmtk-code and adding more ::OutputDebugString methods, but somehow got lost.
If someone has similar problems and / or a solution I would appreciate it.
Code: Select all
DcmFileFormat fileFormat;
DcmDataset *dataset = fileFormat.getDataset();
insertNonQueryData(dataset);
dataset->putAndInsertString(DCM_AccessionNumber, "");
DcmSequenceOfItems *scheduledProcedureSeq = new DcmSequenceOfItems(DCM_ScheduledProcedureStepSequence);
DcmItem *item = new DcmItem();
insertNonQueryDataIntoScheduledProcedureSequence(item);
item->putAndInsertString(DCM_ScheduledStationAETitle, myAetitle.c_str());
char temp[10];
sprintf_s(temp, "%04d%02d%02d", date.wYear, date.wMonth, date.wDay);
item->putAndInsertString(DCM_ScheduledProcedureStepStartDate, temp);
scheduledProcedureSeq->append(item);
dataset->insert(scheduledProcedureSeq);
char filename[MAX_PATH];
char filepath[MAX_PATH-100];
GetTempPathA(MAX_PATH-100, filepath);
if (GetTempFileNameA(filepath, "wlquery", 0, filename))
{
OFCondition status = fileFormat.saveFile(filename, EXS_LittleEndianExplicit, EET_UndefinedLength, EGL_withoutGL);
std::stringstream dicomXML;
dataset->writeXML(dicomXML);
if (status.good())
{
return filename;
}
else
{
ERROROUT(9603, 0, status.text())
}
}