Project

General

Profile

Actions

Feature #1023

closed

Permit OFFile to be used with DcmOutputFileStream

Added by Marco Eichelberg over 3 years ago. Updated almost 3 years ago.

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
Actions

Also available in: Atom PDF