Actions
Feature #1023
closedPermit OFFile to be used with DcmOutputFileStream
Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Library
Target version:
-
Start date:
2022-05-10
Due date:
% Done:
100%
Estimated time:
1:00 h
Module:
ofstd, dcmdata
Operating System:
Compiler:
Description
The following code, when executed on Linux, leads to a segmentation fault:
OFFile* imageFile = new OFFile; DcmOutputFileStream* outStream = nullptr; imageFile->fopen(currentFilename.c_str(), "wb"); outStream = new DcmOutputFileStream(imageFile->file()); delete outStream; delete imageFile;
The reason is that the ''FILE *'' handle is closed twice, once in the OFFile destructor and once in the DcmOutputFileStream destructor. This apparently works on Windows but crashes on Linux.
Possible solutions:- add method in OFFile and/or DcmOutputFileStream that sets the ''FILE *'' to NULL without calling fclose()
- permit an OFFile instance to be passed to DcmOutputFileStream by reference
- add a flag in the constructor in both classes indicating whether or not the file descriptor should be closed in the destructor
Updated by Marco Eichelberg over 3 years ago
Reported 2022-05-04 by Franz Reitner <franz.reitner@excelitas.com>
Updated by Marco Eichelberg almost 3 years ago
- Status changed from New to Closed
- % Done changed from 0 to 100
- Estimated time set to 1:00 h
Closed by commit #0c5d89074.
Actions