[glib] gio: Update GMemoryOutputStream length after truncate
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gio: Update GMemoryOutputStream length after truncate
- Date: Sun, 15 Dec 2013 23:51:15 +0000 (UTC)
commit 3b9ad6e6ef030cd8487f165e8d81174bd82e4fb9
Author: Ross Lagerwall <rosslagerwall gmail com>
Date: Sun Dec 8 22:41:15 2013 +0200
gio: Update GMemoryOutputStream length after truncate
For GMemoryOutputStream, update valid_len when truncating so that
g_memory_output_stream_get_data_size () returns the correct result.
https://bugzilla.gnome.org/show_bug.cgi?id=720080
gio/gmemoryoutputstream.c | 2 ++
gio/tests/memory-output-stream.c | 5 +++++
2 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/gio/gmemoryoutputstream.c b/gio/gmemoryoutputstream.c
index 82747a3..6611ead 100644
--- a/gio/gmemoryoutputstream.c
+++ b/gio/gmemoryoutputstream.c
@@ -828,6 +828,8 @@ g_memory_output_stream_truncate (GSeekable *seekable,
if (!array_resize (ostream, offset, FALSE, error))
return FALSE;
+ ostream->priv->valid_len = offset;
+
return TRUE;
}
diff --git a/gio/tests/memory-output-stream.c b/gio/tests/memory-output-stream.c
index a8b389a..b9be0df 100644
--- a/gio/tests/memory-output-stream.c
+++ b/gio/tests/memory-output-stream.c
@@ -50,6 +50,11 @@ test_truncate (void)
g_assert_no_error (error);
}
+ g_test_bug ("720080");
+
+ g_seekable_truncate (G_SEEKABLE (mo), 8192, NULL, &error);
+ g_assert_cmpint (g_memory_output_stream_get_data_size (G_MEMORY_OUTPUT_STREAM (mo)), ==, 8192);
+
g_object_unref (o);
g_object_unref (mo);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]