@@ -116,35 +116,35 @@ bool RAWCodec::DecodeBytes(const char* inBytes, size_t inBufferLength,
116116 if ( this ->GetPixelFormat () == PixelFormat::UINT12 ||
117117 this ->GetPixelFormat () == PixelFormat::INT12 )
118118 {
119- size_t len = str.size () * 16 / 12 ;
120- char * copy = new char [len];
121- bool b = Unpacker12Bits::Unpack (copy, str.data (), str.size () );
122- if (!b)
123- {
124- delete[] copy;
125- return false ;
126- }
127- gdcm_assert (inOutBufferLength == len);
128- memcpy (outBytes, copy, len);
129-
130- delete[] copy;
131-
132119 this ->GetPixelFormat ().SetBitsAllocated ( 16 );
120+ const size_t len = str.size () * 16 / 12 ;
121+ if (len == inOutBufferLength) {
122+ char * copy = new char [len];
123+ bool b = Unpacker12Bits::Unpack (copy, str.data (), str.size () );
124+ if (!b)
125+ {
126+ delete[] copy;
127+ return false ;
128+ }
129+ gdcm_assert (inOutBufferLength == len);
130+ memcpy (outBytes, copy, len);
131+
132+ delete[] copy;
133+ return r;
133134 }
135+ }
136+
137+ // DermaColorLossLess.dcm
138+ // assert (check == inOutBufferLength || check == inOutBufferLength + 1);
139+ // problem with: SIEMENS_GBS_III-16-ACR_NEMA_1.acr
140+ size_t len = str.size ();
141+ if ( inOutBufferLength <= len )
142+ memcpy (outBytes, str.c_str (), inOutBufferLength);
134143 else
135- {
136- // DermaColorLossLess.dcm
137- // assert (check == inOutBufferLength || check == inOutBufferLength + 1);
138- // problem with: SIEMENS_GBS_III-16-ACR_NEMA_1.acr
139- size_t len = str.size ();
140- if ( inOutBufferLength <= len )
141- memcpy (outBytes, str.c_str (), inOutBufferLength);
142- else
143- {
144- gdcmWarningMacro ( " Requesting too much data. Truncating result" );
145- memcpy (outBytes, str.c_str (), len);
146- }
147- }
144+ {
145+ gdcmWarningMacro ( " Requesting too much data. Truncating result" );
146+ memcpy (outBytes, str.c_str (), len);
147+ }
148148
149149 return r;
150150}
0 commit comments