~ubuntu-branches/ubuntu/saucy/goffice/saucy-proposed

« back to all changes in this revision

Viewing changes to debian/patches/pixbuf-fixes.patch

  • Committer: Package Import Robot
  • Author(s): Dmitry Smirnov
  • Date: 2013-08-30 14:03:56 UTC
  • mfrom: (1.2.35)
  • Revision ID: package-import@ubuntu.com-20130830140356-a1e30nbdku8kg4q0
Tags: 0.10.6-1
* New upstream release [August 2013].
* Dropped backported "pixbuf-fixes.patch".

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Last-Update: 2013-08-08
2
 
Forwarded: not-needed
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.
6
 
 393c569..3bf3453
7
 
 
8
 
--- a/goffice/utils/go-pixbuf.c
9
 
+++ b/goffice/utils/go-pixbuf.c
10
 
@@ -84,10 +84,13 @@
11
 
        g_return_if_fail (GO_IS_PIXBUF (image));
12
 
        pixbuf = GO_PIXBUF (image);
13
 
        gsf_xml_out_add_int (output, "rowstride", pixbuf->rowstride);
14
 
        if (!image->data) {
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");
20
 
+                       return;
21
 
+               }
22
 
                pixbuf_to_cairo (pixbuf);
23
 
        }
24
 
        gsf_xml_out_add_base64
25
 
                (output, NULL,
26
 
@@ -106,15 +109,24 @@
27
 
 static void
28
 
 go_pixbuf_load_data (GOImage *image, GsfXMLIn *xin)
29
 
 {
30
 
        size_t length, expected;
31
 
+       int stride;
32
 
+
33
 
+       stride = go_pixbuf_get_rowstride (GO_PIXBUF (image));
34
 
+       g_return_if_fail (stride > 0);
35
 
+
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,
45
 
+                           expected, length);
46
 
+       image->data = g_try_malloc (expected);
47
 
+       if (image->data == NULL) {
48
 
+               g_critical ("go_pixbuf_load_data: assertion `image->data != NULL' failed");
49
 
+               return;
50
 
+       }
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);
54
 
 }
55
 
 
56
 
@@ -125,10 +137,13 @@
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");
66
 
+                               return;
67
 
+                       }
68
 
                        pixbuf_to_cairo (pixbuf);
69
 
                }
70
 
                pixbuf->surface = cairo_image_surface_create_for_data (image->data,
71
 
                                                                       CAIRO_FORMAT_ARGB32,