1
Last-Update: 2013-08-08
3
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=719034
4
Author: Dmitry Smirnov <onlyjob@member.fsf.org>
5
Description: cherry-picked (backported) upstream pixbuf fixes.
8
--- a/goffice/utils/go-pixbuf.c
9
+++ b/goffice/utils/go-pixbuf.c
11
g_return_if_fail (GO_IS_PIXBUF (image));
12
pixbuf = GO_PIXBUF (image);
13
gsf_xml_out_add_int (output, "rowstride", pixbuf->rowstride);
15
- image->data = g_new0 (guint8, image->height * pixbuf->rowstride);
16
- g_return_if_fail (image->data !=NULL);
17
+ image->data = g_try_new0 (guint8, image->height * pixbuf->rowstride);
18
+ if (image->data == NULL) {
19
+ g_critical ("go_pixbuf_save: assertion `image->data != NULL' failed");
22
pixbuf_to_cairo (pixbuf);
24
gsf_xml_out_add_base64
28
go_pixbuf_load_data (GOImage *image, GsfXMLIn *xin)
30
size_t length, expected;
33
+ stride = go_pixbuf_get_rowstride (GO_PIXBUF (image));
34
+ g_return_if_fail (stride > 0);
36
length = gsf_base64_decode_simple (xin->content->str, strlen(xin->content->str));
37
- expected = image->height * go_pixbuf_get_rowstride (GO_PIXBUF (image));
38
+ expected = image->height * (size_t)stride;
39
if (expected != length)
40
- g_critical ("Invalid image size, expected %lu bytes, got %lu", expected, length);
41
- image->data = g_malloc (expected);
42
- g_return_if_fail (image->data !=NULL);
43
- memcpy (image->data, xin->content->str, (length < expected)? length: expected);
44
+ g_critical ("Invalid image size, expected %" G_GSIZE_FORMAT " bytes, got %" G_GSIZE_FORMAT,
46
+ image->data = g_try_malloc (expected);
47
+ if (image->data == NULL) {
48
+ g_critical ("go_pixbuf_load_data: assertion `image->data != NULL' failed");
51
+ memcpy (image->data, xin->content->str, MIN (length, expected));
52
if (length < expected) /* fill with 0 */
53
memset (image->data + length, 0, expected - length);
57
g_return_if_fail (pixbuf);
58
if (pixbuf->surface == NULL) {
59
if (image->data == NULL) {
60
/* image built from a pixbuf */
61
- image->data = g_new0 (guint8, image->height * pixbuf->rowstride);
62
- g_return_if_fail (image->data !=NULL);
63
+ image->data = g_try_new0 (guint8, image->height * pixbuf->rowstride);
64
+ if (image->data == NULL) {
65
+ g_critical ("go_pixbuf_load_data: assertion `image->data != NULL' failed");
68
pixbuf_to_cairo (pixbuf);
70
pixbuf->surface = cairo_image_surface_create_for_data (image->data,