[goffice] Avoid writing to a NULL buffer for an invalid GOPixbuf.
- From: Jean Bréfort <jbrefort src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] Avoid writing to a NULL buffer for an invalid GOPixbuf.
- Date: Mon, 8 Jul 2013 14:48:13 +0000 (UTC)
commit 7bc785433ececa5be3ed2fdc9e98d267c97d5da3
Author: Jean Brefort <jean brefort normalesup org>
Date: Mon Jul 8 16:45:37 2013 +0200
Avoid writing to a NULL buffer for an invalid GOPixbuf.
ChangeLog | 5 +++++
goffice/utils/go-pixbuf.c | 3 +++
2 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e8bce69..9aaa96c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2013-07-08 Jean Brefort <jean brefort normalesup org>
+ * goffice/utils/go-pixbuf.c (go_pixbuf_save),
+ (go_pixbuf_load_data), (go_pixbuf_draw): avoid writing to a NULL buffer.
+
+2013-07-08 Jean Brefort <jean brefort normalesup org>
+
* goffice/utils/go-pixbuf.c (go_pixbuf_load_data): fix loading of image with
invalid size or data. [#703740]
diff --git a/goffice/utils/go-pixbuf.c b/goffice/utils/go-pixbuf.c
index 0675249..cef0033 100644
--- a/goffice/utils/go-pixbuf.c
+++ b/goffice/utils/go-pixbuf.c
@@ -86,6 +86,7 @@ go_pixbuf_save (GOImage *image, GsfXMLOut *output)
gsf_xml_out_add_int (output, "rowstride", pixbuf->rowstride);
if (!image->data) {
image->data = g_new0 (guint8, image->height * pixbuf->rowstride);
+ g_return_if_fail (image->data !=NULL);
pixbuf_to_cairo (pixbuf);
}
gsf_xml_out_add_base64
@@ -111,6 +112,7 @@ go_pixbuf_load_data (GOImage *image, GsfXMLIn *xin)
if (expected != length)
g_critical ("Invalid image size, expected %lu bytes, got %lu", expected, length);
image->data = g_malloc (expected);
+ g_return_if_fail (image->data !=NULL);
memcpy (image->data, xin->content->str, (length < expected)? length: expected);
if (length < expected) /* fill with 0 */
memset (image->data + length, 0, expected - length);
@@ -125,6 +127,7 @@ go_pixbuf_draw (GOImage *image, cairo_t *cr)
if (image->data == NULL) {
/* image built from a pixbuf */
image->data = g_new0 (guint8, image->height * pixbuf->rowstride);
+ g_return_if_fail (image->data !=NULL);
pixbuf_to_cairo (pixbuf);
}
pixbuf->surface = cairo_image_surface_create_for_data (image->data,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]