Details
-
Bug
-
Resolution: Out of scope
-
Not Evaluated
-
None
-
1.1.0
-
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'