Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-52

QImage modifies supposedly immutable strings

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 1.1.0
    • PySide
    • None
    • Desktop - Windows, MacOS or Linux.

    Description

      When QImage is passed a Python string it appears to be failing to create a local copy. This results in two issues: One is that setPixel modifies the supposedly immutable Python string causing all of havoc. Two is that it doesn't appear to hold a strong reference to the string so if the string becomes deallocated the application can crash.

      Example of string mutation:

      In [14]: app = QApplication([])

      In [16]: s = '\xff\xff\xff\xff'

      In [17]: img = QImage(s, 1, 1, QImage.Format_ARGB32)

      In [19]: img.pixel(0, 0)
      Out[19]: 4294967295L

      In [20]: s
      Out[20]: '\xff\xff\xff\xff'

      In [22]: img.setPixel(0, 0, 4294967290)

      In [23]: s
      Out[23]: '\xfa\xff\xff\xff'

      In [25]: img.setPixel(0, 0, 0)

      In [26]: s
      Out[26]: '\x00\x00\x00\x00'

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            jasonmccampbell Jason McCampbell
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes