[gimp] Bug 731390 - XCF files have a max size of 4G
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 731390 - XCF files have a max size of 4G
- Date: Thu, 23 Mar 2017 12:17:08 +0000 (UTC)
commit 829bad4063c5914e74ef9a4b988e0ee5bfaaae44
Author: Michael Natterer <mitch gimp org>
Date: Thu Mar 23 13:16:13 2017 +0100
Bug 731390 - XCF files have a max size of 4G
Add support for 64 bit offsets to xcf_read_offset() and
xcf_write_offset(), but don't use the feature yet.
app/xcf/xcf-read.c | 28 +++++++++++++++++++++-------
app/xcf/xcf-write.c | 27 +++++++++++++++++++--------
2 files changed, 40 insertions(+), 15 deletions(-)
---
diff --git a/app/xcf/xcf-read.c b/app/xcf/xcf-read.c
index 489ccb8..3431265 100644
--- a/app/xcf/xcf-read.c
+++ b/app/xcf/xcf-read.c
@@ -58,18 +58,32 @@ xcf_read_offset (XcfInfo *info,
goffset *data,
gint count)
{
- guint total = 0;
- gint32 *int_offsets = g_alloca (count * sizeof (gint32));
+ guint total = 0;
if (count > 0)
{
- total += xcf_read_int8 (info, (guint8 *) int_offsets, count * 4);
+ if (info->bytes_per_offset == 4)
+ {
+ gint32 *int_offsets = g_alloca (count * sizeof (gint32));
- while (count--)
+ total += xcf_read_int8 (info, (guint8 *) int_offsets, count * 4);
+
+ while (count--)
+ {
+ *data = g_ntohl (*int_offsets);
+ int_offsets++;
+ data++;
+ }
+ }
+ else
{
- *data = g_ntohl (*int_offsets);
- int_offsets++;
- data++;
+ total += xcf_read_int8 (info, (guint8 *) data, count * 8);
+
+ while (count--)
+ {
+ *data = GINT64_FROM_BE (*data);
+ data++;
+ }
}
}
diff --git a/app/xcf/xcf-write.c b/app/xcf/xcf-write.c
index 83ea9b0..313c830 100644
--- a/app/xcf/xcf-write.c
+++ b/app/xcf/xcf-write.c
@@ -64,16 +64,26 @@ xcf_write_offset (XcfInfo *info,
gint count,
GError **error)
{
- GError *tmp_error = NULL;
- gint i;
-
if (count > 0)
{
+ gint i;
+
for (i = 0; i < count; i++)
{
- guint32 tmp = g_htonl (data[i]);
+ GError *tmp_error = NULL;
- xcf_write_int8 (info, (const guint8 *) &tmp, 4, &tmp_error);
+ if (info->bytes_per_offset == 4)
+ {
+ guint32 tmp = g_htonl (data[i]);
+
+ xcf_write_int8 (info, (const guint8 *) &tmp, 4, &tmp_error);
+ }
+ else
+ {
+ gint64 tmp = GINT64_TO_BE (data[i]);
+
+ xcf_write_int8 (info, (const guint8 *) &tmp, 8, &tmp_error);
+ }
if (tmp_error)
{
@@ -94,11 +104,12 @@ xcf_write_zero_offset (XcfInfo *info,
{
if (count > 0)
{
- guint32 *tmp = g_alloca (count * 4);
+ guint8 *tmp = g_alloca (count * info->bytes_per_offset);
- memset (tmp, 0, count * 4);
+ memset (tmp, 0, count * info->bytes_per_offset);
- return xcf_write_int8 (info, (const guint8 *) tmp, count * 4, error);
+ return xcf_write_int8 (info, (const guint8 *) tmp,
+ count * info->bytes_per_offset, error);
}
return 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]