Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu karmic ubuntu-patch

Hello,

This was also reported to Ubuntu:
https://bugs.launchpad.net/bugs/395204

The attached patch fixes the issue.

Thanks,

-Kees

-- 
Kees Cook                                            @debian.org
diff -u pygdchart2-0.beta1/_gdchartc.c pygdchart2-0.beta1/_gdchartc.c
--- pygdchart2-0.beta1/_gdchartc.c
+++ pygdchart2-0.beta1/_gdchartc.c
@@ -707,22 +707,22 @@
         return NULL;
     }
     for (i = 0; i < len; i++){
+        char * cstr = NULL;
         pobj = PySequence_GetItem(lst, i);
         pstr = PyObject_Str(pobj);
         Py_DECREF(pobj);
         if (pstr == NULL)
             goto cleanup;
-        slen = PyString_Size(pstr);
-        if (slen = 0)
+        cstr = PyString_AsString(pstr);
+        mem = strdup(cstr ? cstr : "");
+        strings[i] = mem;
+        Py_DECREF(pstr);
+        if (!cstr)
             goto cleanup;
-        mem = malloc((size_t)slen+1);
         if (mem == NULL){
             PyErr_NoMemory();
             goto cleanup;
         }
-        strcpy(mem, PyString_AsString(pstr));
-        Py_DECREF(pstr);
-        strings[i] = mem;
     }
     return strings;
 

Reply via email to