Skip to content

Fix double-delete in DcmJSONReader::clear() - #131

Closed
Oss-Auditor wants to merge 1 commit into
DCMTK:masterfrom
Oss-Auditor:fix-double-delete
Closed

Fix double-delete in DcmJSONReader::clear()#131
Oss-Auditor wants to merge 1 commit into
DCMTK:masterfrom
Oss-Auditor:fix-double-delete

Conversation

@Oss-Auditor

Copy link
Copy Markdown

Set jsonDataset_ and tokenArray_ to NULL after deletion to prevent double-delete when the object is reused (e.g., calling readAndConvertJSONFile() multiple times).

The reserveTokens() method deletes tokenArray_ without checking if it's already freed, causing crashes on second use.

Set jsonDataset_ and tokenArray_ to NULL after deletion to prevent
double-delete when the object is reused (e.g., calling
readAndConvertJSONFile() multiple times).

The reserveTokens() method deletes tokenArray_ without checking if
it's already freed, causing crashes on second use.
@michaelonken

Copy link
Copy Markdown
Member

I think the fix works (just tried it).

@eichelberg: maybe one can call clear() also earlier in (e.g. just in the beginning of readAndConvertJSONFile()) in order to make the code easier to understand.

@eichelberg

Copy link
Copy Markdown
Member

Thank you. I just merged the PR (plus Michael's suggestion) into our testing branch. It will appear in the public repository in a few days.

@eichelberg eichelberg closed this Oct 28, 2025
michaelonken pushed a commit that referenced this pull request Nov 4, 2025
DcmJSONReader::clear() now sets jsonDataset_ and tokenArray_ to NULL after
deletion to prevent double-delete when the object is reused.

Thanks to GitHub user "Oss-Auditor" for the pull request.

This closes GitHub PR #131.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants