Skip to content

Commit

Permalink
Further enhanced computation of buffer size when using partial read a…
Browse files Browse the repository at this point in the history
…ccess

to pixel data. Now also some rare cases of BitsAllocated are supported.
  • Loading branch information
Joerg Riesmeier committed Apr 16, 2010
1 parent 5a076aa commit 175a834
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGES.355
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@

Changes between releases are documented here.

**** Changes from 2010.04.16 (riesmeier)

- Further enhanced computation of buffer size when using partial read access
to pixel data. Now also some rare cases of BitsAllocated are supported.
Affects: dcmimgle/include/dcmtk/dcmimgle/diinpxt.h

**** Changes from 2010.04.15 (riesmeier)

- Fixed possibly wrong computation of a buffer size when using partial read
Expand Down
19 changes: 11 additions & 8 deletions dcmimgle/include/dcmtk/dcmimgle/diinpxt.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
* Purpose: DicomInputPixelTemplate (Header)
*
* Last Update: $Author: joergr $
* Update Date: $Date: 2010-04-15 14:18:36 $
* CVS/RCS Revision: $Revision: 1.39 $
* Update Date: $Date: 2010-04-16 12:56:46 $
* CVS/RCS Revision: $Revision: 1.40 $
* Status: $State: Exp $
*
* CVS/RCS Log at end of file
Expand Down Expand Up @@ -377,13 +377,12 @@ class DiInputPixelTemplate
if ((document->getFlags() & CIF_UsePartialAccessToPixelData) && (PixelCount > 0) &&
(!uncompressed || !pixelData->valueLoaded()) && (bitsAllocated % 8 == 0))
{
/* Bits Allocated is always a multiple of 8 (see above) */
const Uint32 byteFactor = (bitsAllocated / 8);
/* need to split the calculation in order to avoid integer overflow for large pixel data */
const Uint32 count_B1 = bitsof_T1 / bitsAllocated;
const Uint32 count_T1 = (count_B1 > 0) ? PixelCount / count_B1 : PixelCount * (bitsAllocated / bitsof_T1);
/* Bits Allocated is always a multiple of 8 (see above), same for bits of T1 */
const Uint32 byteFactor = bitsAllocated / 8;
const Uint32 bytes_T1 = bitsof_T1 / 8;
const Uint32 count_T1 = (byteFactor == bytes_T1) ? PixelCount : (PixelCount * byteFactor + bytes_T1 - 1) / bytes_T1;
#ifdef DEBUG
DCMIMGLE_TRACE("PixelCount: " << PixelCount << ", byteFactor: " << byteFactor << ", count_B1: " << count_B1 << ", count_T1: " << count_T1);
DCMIMGLE_TRACE("PixelCount: " << PixelCount << ", byteFactor: " << byteFactor << ", bytes_T1: " << bytes_T1 << ", count_T1: " << count_T1);
#endif
/* allocate temporary buffer */
pixel = new T1[count_T1];
Expand Down Expand Up @@ -643,6 +642,10 @@ class DiInputPixelTemplate
*
* CVS/RCS Log:
* $Log: diinpxt.h,v $
* Revision 1.40 2010-04-16 12:56:46 joergr
* Further enhanced computation of buffer size when using partial read access
* to pixel data. Now also some rare cases of BitsAllocated are supported.
*
* Revision 1.39 2010-04-15 14:18:36 joergr
* Fixed possibly wrong computation of a buffer size when using partial read
* access to pixel data. This could lead to a crash under certain conditions.
Expand Down

0 comments on commit 175a834

Please sign in to comment.