| author | Guillaume Seguin <guillaume@segu.in> | 2010-04-20 17:38:53 (GMT) |
|---|---|---|
| committer | Emmanuele Bassi <ebassi@linux.intel.com> | 2010-04-20 17:38:53 (GMT) |
| commit | c05436ed9c236c060628e5a09ce8d32ade58cca2 (patch) (side-by-side diff) | |
| tree | fcdb87c43afba3b56f6984667a8cf013c3ddc9af | |
| parent | 7a5b4cb27b9925b80e8d7cacedcd1277648b067f (diff) | |
| download | pyclutter-c05436ed9c236c060628e5a09ce8d32ade58cca2.zip pyclutter-c05436ed9c236c060628e5a09ce8d32ade58cca2.tar.gz | |
Use an explicitly sized string for Stage.read_pixels() return value
The return value for clutter.Stage.read_pixels() is a binary blob
representing a linear buffer of RGBA 8bit data with a rowstride of
4 * width. Using Py_BuildValue("s") is not a good idea, as it assumes
that the string is going to be NUL-terminated. We should use the "s#"
signature and pass the length of the buffer instead.
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
| -rw-r--r-- | clutter/clutter.override | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/clutter/clutter.override b/clutter/clutter.override index 5845e94..1386fc6 100644 --- a/clutter/clutter.override +++ b/clutter/clutter.override @@ -759,10 +759,17 @@ _wrap_clutter_stage_read_pixels(PyGObject *self, ret = clutter_stage_read_pixels(CLUTTER_STAGE(self->obj), x, y, width, height); if (ret) { - PyObject *py_ret = Py_BuildValue("s", ret); + PyObject *py_ret; + + /* by definition, the returned buffer is RGBA 8bit data with a + * rowstride of width * 4 + */ + py_ret = Py_BuildValue("s#", ret, height * width * 4); g_free(ret); + return py_ret; } + Py_INCREF(Py_None); return Py_None; } |
