[libgsf] GsfInfileMSOle: fix dup.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgsf] GsfInfileMSOle: fix dup.
- Date: Wed, 5 Dec 2012 16:02:47 +0000 (UTC)
commit 54e0b3f07bebd5028a8cfc89e81359b83b3386e6
Author: Morten Welinder <terra gnome org>
Date: Wed Dec 5 11:00:03 2012 -0500
GsfInfileMSOle: fix dup.
ChangeLog | 10 +++++++++
NEWS | 3 ++
gsf/gsf-infile-msole.c | 31 +++++++++++-----------------
tests/Makefile.am | 1 +
tests/test-msole-dup.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 77 insertions(+), 19 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e7ddf20..1a15aba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2012-12-05 Morten Welinder <terra gnome org>
+
+ * gsf/gsf-infile-msole.c (gsf_infile_msole_child_by_index)
+ (gsf_infile_msole_name_by_index): Avoid casts.
+
+2012-12-05 Paolo Bonzini <bonzini gnu org>
+
+ * gsf/gsf-infile-msole.c (gsf_infile_msole_dup): Make this a
+ simple wrapper over gsf_infile_msole_dup. Fixes #689706.
+
2012-11-13 Morten Welinder <terra gnome org>
* configure.in: Post-release bump.
diff --git a/NEWS b/NEWS
index e0e86e1..f52c5f4 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
libgsf 1.14.26
+Paolo Bonzini:
+ * Fix gsf_input_dep for msole streams. [#689706]
+
--------------------------------------------------------------------------
libgsf 1.14.25
diff --git a/gsf/gsf-infile-msole.c b/gsf/gsf-infile-msole.c
index be617c0..3439f11 100644
--- a/gsf/gsf-infile-msole.c
+++ b/gsf/gsf-infile-msole.c
@@ -640,20 +640,9 @@ static GsfInput *
gsf_infile_msole_dup (GsfInput *src_input, GError **err)
{
GsfInfileMSOle const *src = GSF_INFILE_MSOLE (src_input);
- GsfInfileMSOle *dst = ole_dup (src, err);
+ GsfInfileMSOle *parent = GSF_INFILE_MSOLE (gsf_input_container (src_input));
- if (dst == NULL)
- return NULL;
-
- if (src->bat.block != NULL) {
- dst->bat.block = g_new (guint32, src->bat.num_blocks),
- memcpy (dst->bat.block, src->bat.block,
- sizeof (guint32) * src->bat.num_blocks);
- }
- dst->bat.num_blocks = src->bat.num_blocks;
- dst->dirent = src->dirent;
-
- return GSF_INPUT (dst);
+ return gsf_infile_msole_new_child (parent, src->dirent, err);
}
static guint8 const *
@@ -801,7 +790,7 @@ gsf_infile_msole_new_child (GsfInfileMSOle *parent,
for (i = 0 ; remaining > 0 && i < child->bat.num_blocks; i++, remaining -= info->sb.size)
if (gsf_input_seek (GSF_INPUT (sb_file),
- (gsf_off_t)(child->bat.block [i] << info->sb.shift), G_SEEK_SET) < 0 ||
+ (gsf_off_t)(child->bat.block [i] << info->sb.shift), G_SEEK_SET) < 0 ||
(data = gsf_input_read (GSF_INPUT (sb_file),
MIN (remaining, (int)info->sb.size),
child->stream.buf + (i << info->sb.shift))) == NULL) {
@@ -829,10 +818,12 @@ gsf_infile_msole_child_by_index (GsfInfile *infile, int target, GError **err)
GsfInfileMSOle *ole = GSF_INFILE_MSOLE (infile);
GList *p;
- for (p = ole->dirent->children; p != NULL ; p = p->next)
+ for (p = ole->dirent->children; p != NULL ; p = p->next) {
+ MSOleDirent *dirent = p->data;
if (target-- <= 0)
- return gsf_infile_msole_new_child (ole,
- (MSOleDirent *)p->data, err);
+ return gsf_infile_msole_new_child
+ (ole, dirent, err);
+ }
return NULL;
}
@@ -842,9 +833,11 @@ gsf_infile_msole_name_by_index (GsfInfile *infile, int target)
GsfInfileMSOle *ole = GSF_INFILE_MSOLE (infile);
GList *p;
- for (p = ole->dirent->children; p != NULL ; p = p->next)
+ for (p = ole->dirent->children; p != NULL ; p = p->next) {
+ MSOleDirent *dirent = p->data;
if (target-- <= 0)
- return ((MSOleDirent *)p->data)->name;
+ return dirent->name;
+ }
return NULL;
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b566b00..6599580 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -2,6 +2,7 @@ AM_CPPFLAGS = -I$(top_srcdir) $(LIBGSF_CFLAGS) $(LIBXML_CFLAGS)
LDADD = $(top_builddir)/gsf/libgsf-1.la $(LIBGSF_LIBS)
check_PROGRAMS = test-msole1 test-msole2 test-cp-msole test-msvba \
+ test-msole-dup \
test-zip1 test-input1 test-cp \
test-textline test-ls-zip test-cat-zip test-zip2 \
test-cp-zip test-out-printf test-outmem-printf \
diff --git a/tests/test-msole-dup.c b/tests/test-msole-dup.c
new file mode 100644
index 0000000..2e56864
--- /dev/null
+++ b/tests/test-msole-dup.c
@@ -0,0 +1,51 @@
+#include <stdbool.h>
+#include <unistd.h>
+#include <gsf/gsf.h>
+#include <gsf/gsf-input.h>
+#include <gsf/gsf-infile.h>
+#include <gsf/gsf-output.h>
+#include <gsf/gsf-outfile.h>
+#include <gsf/gsf-input-memory.h>
+#include <gsf/gsf-input-stdio.h>
+#include <gsf/gsf-output-stdio.h>
+#include <gsf/gsf-infile-msole.h>
+#include <gsf/gsf-outfile-msole.h>
+
+int
+main (int argc, char **argv)
+{
+ GsfOutput *out, *outchild;
+ GsfOutfile *outf;
+ GsfInput *in, *inchild, *indup;
+ GsfInfile *inf;
+ gsize size;
+
+ (void)argc;
+ (void)argv;
+
+ g_type_init();
+
+ out = gsf_output_stdio_new("teststg", NULL);
+ outf = gsf_outfile_msole_new(out);
+ outchild = gsf_outfile_new_child(outf, "small", false);
+ gsf_output_puts(outchild, "test\n");
+ gsf_output_close(outchild);
+ g_object_unref(G_OBJECT(outchild));
+ gsf_output_close(GSF_OUTPUT(outf));
+ g_object_unref(G_OBJECT(outf));
+ g_object_unref(G_OBJECT(out));
+
+ in = gsf_input_stdio_new("teststg", NULL);
+ inf = gsf_infile_msole_new(in, NULL);
+ inchild = gsf_infile_child_by_name(inf, "small");
+ indup = gsf_input_dup(inchild, NULL);
+ size = gsf_input_size(inchild);
+
+ write(1, gsf_input_read(indup, size, NULL), size);
+ g_object_unref(G_OBJECT(indup));
+ g_object_unref(G_OBJECT(inchild));
+ g_object_unref(G_OBJECT(inf));
+ g_object_unref(G_OBJECT(in));
+
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]