From 371c2d937e37b08a46eeb0628c553ce4608a45df Mon Sep 17 00:00:00 2001 From: Mathieu Malaterre Date: Wed, 21 Feb 2024 02:18:35 -0800 Subject: [PATCH] Remove symptoms from TALOS-2024-1935 diff --git a/Source/MediaStorageAndFileFormat/gdcmImageChangeTransferSyntax.cxx b/Source/MediaStorageAndFileFormat/gdcmImageChangeTransferSyntax.cxx index fcb61e611..9457c5e9b 100644 --- a/Source/MediaStorageAndFileFormat/gdcmImageChangeTransferSyntax.cxx +++ b/Source/MediaStorageAndFileFormat/gdcmImageChangeTransferSyntax.cxx @@ -421,6 +421,7 @@ bool ImageChangeTransferSyntax::Change() if( !b ) { gdcmErrorMacro( "Error in getting buffer from input image." ); + delete bv0; return false; } pixeldata.SetValue( *bv0 ); diff --git a/Source/MediaStorageAndFileFormat/gdcmJPEG2000Codec.cxx b/Source/MediaStorageAndFileFormat/gdcmJPEG2000Codec.cxx index 10ac23cca..430a24a87 100644 --- a/Source/MediaStorageAndFileFormat/gdcmJPEG2000Codec.cxx +++ b/Source/MediaStorageAndFileFormat/gdcmJPEG2000Codec.cxx @@ -826,8 +826,13 @@ std::pair JPEG2000Codec::DecodeByStreamsCommon(char *dummy_buffe // ELSCINT1_JP2vsJ2K.dcm // -> prec = 12, bpp = 0, sgnd = 0 - //assert( wr == Dimensions[0] ); - //assert( hr == Dimensions[1] ); + if( wr != Dimensions[0] || hr != Dimensions[1] ) { + gdcmErrorMacro("Invalid dimension"); + delete[] raw; + opj_destroy_codec(dinfo); + opj_image_destroy(image); + return std::pair(nullptr,0); + } if( comp->sgnd != PF.GetPixelRepresentation() ) { PF.SetPixelRepresentation( (uint16_t)comp->sgnd );