Page 1 of 1

DICOM codec crashes while reading

Posted: 2011-04-25T20:20:33-07:00
by purrquay
When reading certain DICOM files (of which this is an example), the codec crashes in 2 places, both due to dereferencing a null pointer:

The following is an excerpt from dcm.c from line 3253:

Code: Select all

          case 0x1050:
          {
            /*
              Visible pixel range: center.
            */
            window_center=StringToLong((char *) data);
            break;
          }
          case 0x1051:
          {
            /*
              Visible pixel range: width.
            */
            window_width=StringToUnsignedLong((char *) data);
            break;
          }
The fix is simple, and does not seem to have side effects:

Code: Select all

          case 0x1050:
          {
            /*
              Visible pixel range: center.
            */
            if (data != NULL)
              window_center=StringToLong((char *) data);
            break;
          }
          case 0x1051:
          {
            /*
              Visible pixel range: width.
            */
            if (data != NULL)
              window_width=StringToUnsignedLong((char *) data);
            break;
          }