Package: python-pygame
Version: 1.7.1release-4.1+b1sam1
Severity: important

The attached python code does not seem to work. If I patch pygame with
the attached patch, it is revealed that the call to
PyString_AsStringAndSize in image_fromstring is corrupting the value of
h, causing the image size sanity check later in the code to fail!

$ ./pyg1.py 
h = 192
h = 0
Traceback (most recent call last):
  File "./pyg1.py", line 7, in <module>
    i = pygame.image.fromstring (str (s.get_data ()), (256, 192), 'RGBA')
ValueError: String length does not equal format and resolution size

-- System Information:
Debian Release: lenny/sid
  APT prefers testing
  APT policy: (530, 'testing'), (520, 'unstable'), (510, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.25-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages python-pygame depends on:
ii  libc6                2.7-10              GNU C Library: Shared libraries
ii  libsdl-image1.2      1.2.6-3             image loading library for Simple D
ii  libsdl-mixer1.2      1.2.8-3             mixer library for Simple DirectMed
ii  libsdl-ttf2.0-0      2.0.9-1             ttf library for Simple DirectMedia
ii  libsdl1.2debian      1.2.13-2            Simple DirectMedia Layer
ii  libsmpeg0            0.4.5+cvs20030824-2 SDL MPEG Player Library - shared l
ii  python               2.5.2-1             An interactive high-level object-o
ii  python-central       0.6.6               register and build utility for Pyt
ii  python-numeric       24.2-8.2            Numerical (matrix-oriented) Mathem

python-pygame recommends no packages.

-- no debconf information
#!/usr/bin/python

import cairo
import pygame

s = cairo.ImageSurface (cairo.FORMAT_ARGB32, 256, 192)
i = pygame.image.fromstring (str (s.get_data ()), (256, 192), 'RGBA')
diff --git a/src/image.c b/src/image.c
index 3deb089..40cba47 100644
--- a/src/image.c
+++ b/src/image.c
@@ -20,6 +20,8 @@
     [EMAIL PROTECTED]
 */
 
+#include <stdio.h>
+
 /*
  *  image module for pygame
  */
@@ -614,7 +616,9 @@ PyObject* image_fromstring(PyObject* self, PyObject* arg)
 	if(w < 1 || h < 1)
 		return RAISE(PyExc_ValueError, "Resolution must be positive values");
 
+	fprintf (stderr, "h = %i\n", h);
 	PyString_AsStringAndSize(string, &data, &len);
+	fprintf (stderr, "h = %i\n", h);
 
 	if(!strcmp(format, "P"))
 	{

Reply via email to