0 | |
Last-Update: 2013-08-08
|
1 | |
Forwarded: not-needed
|
2 | |
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=719034
|
3 | |
Author: Dmitry Smirnov <onlyjob@member.fsf.org>
|
4 | |
Description: cherry-picked (backported) upstream pixbuf fixes.
|
5 | |
393c569..3bf3453
|
6 | |
|
7 | |
--- a/goffice/utils/go-pixbuf.c
|
8 | |
+++ b/goffice/utils/go-pixbuf.c
|
9 | |
@@ -84,10 +84,13 @@
|
10 | |
g_return_if_fail (GO_IS_PIXBUF (image));
|
11 | |
pixbuf = GO_PIXBUF (image);
|
12 | |
gsf_xml_out_add_int (output, "rowstride", pixbuf->rowstride);
|
13 | |
if (!image->data) {
|
14 | |
- image->data = g_new0 (guint8, image->height * pixbuf->rowstride);
|
15 | |
- g_return_if_fail (image->data !=NULL);
|
16 | |
+ image->data = g_try_new0 (guint8, image->height * pixbuf->rowstride);
|
17 | |
+ if (image->data == NULL) {
|
18 | |
+ g_critical ("go_pixbuf_save: assertion `image->data != NULL' failed");
|
19 | |
+ return;
|
20 | |
+ }
|
21 | |
pixbuf_to_cairo (pixbuf);
|
22 | |
}
|
23 | |
gsf_xml_out_add_base64
|
24 | |
(output, NULL,
|
25 | |
@@ -106,15 +109,24 @@
|
26 | |
static void
|
27 | |
go_pixbuf_load_data (GOImage *image, GsfXMLIn *xin)
|
28 | |
{
|
29 | |
size_t length, expected;
|
30 | |
+ int stride;
|
31 | |
+
|
32 | |
+ stride = go_pixbuf_get_rowstride (GO_PIXBUF (image));
|
33 | |
+ g_return_if_fail (stride > 0);
|
34 | |
+
|
35 | |
length = gsf_base64_decode_simple (xin->content->str, strlen(xin->content->str));
|
36 | |
- expected = image->height * go_pixbuf_get_rowstride (GO_PIXBUF (image));
|
37 | |
+ expected = image->height * (size_t)stride;
|
38 | |
if (expected != length)
|
39 | |
- g_critical ("Invalid image size, expected %lu bytes, got %lu", expected, length);
|
40 | |
- image->data = g_malloc (expected);
|
41 | |
- g_return_if_fail (image->data !=NULL);
|
42 | |
- memcpy (image->data, xin->content->str, (length < expected)? length: expected);
|
43 | |
+ g_critical ("Invalid image size, expected %" G_GSIZE_FORMAT " bytes, got %" G_GSIZE_FORMAT,
|
44 | |
+ expected, length);
|
45 | |
+ image->data = g_try_malloc (expected);
|
46 | |
+ if (image->data == NULL) {
|
47 | |
+ g_critical ("go_pixbuf_load_data: assertion `image->data != NULL' failed");
|
48 | |
+ return;
|
49 | |
+ }
|
50 | |
+ memcpy (image->data, xin->content->str, MIN (length, expected));
|
51 | |
if (length < expected) /* fill with 0 */
|
52 | |
memset (image->data + length, 0, expected - length);
|
53 | |
}
|
54 | |
|
55 | |
@@ -125,10 +137,13 @@
|
56 | |
g_return_if_fail (pixbuf);
|
57 | |
if (pixbuf->surface == NULL) {
|
58 | |
if (image->data == NULL) {
|
59 | |
/* image built from a pixbuf */
|
60 | |
- image->data = g_new0 (guint8, image->height * pixbuf->rowstride);
|
61 | |
- g_return_if_fail (image->data !=NULL);
|
62 | |
+ image->data = g_try_new0 (guint8, image->height * pixbuf->rowstride);
|
63 | |
+ if (image->data == NULL) {
|
64 | |
+ g_critical ("go_pixbuf_load_data: assertion `image->data != NULL' failed");
|
65 | |
+ return;
|
66 | |
+ }
|
67 | |
pixbuf_to_cairo (pixbuf);
|
68 | |
}
|
69 | |
pixbuf->surface = cairo_image_surface_create_for_data (image->data,
|
70 | |
CAIRO_FORMAT_ARGB32,
|