[Swfdec] 2 commits - libswfdec/swfdec_bits.c
Benjamin Otte
company at kemper.freedesktop.org
Mon Sep 17 04:23:31 PDT 2007
libswfdec/swfdec_bits.c | 52 ++++++++++++++----------------------------------
1 file changed, 16 insertions(+), 36 deletions(-)
New commits:
diff-tree 66b4014d57faa03a37e3d11788110bad17c860e6 (from ca10e69db70a8396253e0fa2114bd6e3787d61d2)
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Sep 17 11:31:24 2007 +0200
more bad duplication
diff --git a/libswfdec/swfdec_bits.c b/libswfdec/swfdec_bits.c
index bddef90..2d1551a 100644
--- a/libswfdec/swfdec_bits.c
+++ b/libswfdec/swfdec_bits.c
@@ -599,12 +599,14 @@ swfdec_bits_get_rgba (SwfdecBits * bits)
}
static inline SwfdecGradient *
-swfdec_bits_do_get_gradient (SwfdecBits *bits, gboolean alpha)
+swfdec_bits_do_get_gradient (SwfdecBits *bits, gboolean alpha, gboolean morph)
{
SwfdecGradient *grad;
guint i, n_gradients;
n_gradients = swfdec_bits_get_u8 (bits);
+ if (morph)
+ n_gradients *= 2;
grad = g_malloc (sizeof (SwfdecGradient) +
sizeof (SwfdecGradientEntry) * (MAX (n_gradients, 1) - 1));
for (i = 0; i < n_gradients && swfdec_bits_left (bits); i++) {
@@ -625,35 +627,19 @@ swfdec_bits_do_get_gradient (SwfdecBits
SwfdecGradient *
swfdec_bits_get_gradient (SwfdecBits * bits)
{
- return swfdec_bits_do_get_gradient (bits, FALSE);
+ return swfdec_bits_do_get_gradient (bits, FALSE, FALSE);
}
SwfdecGradient *
swfdec_bits_get_gradient_rgba (SwfdecBits * bits)
{
- return swfdec_bits_do_get_gradient (bits, TRUE);
+ return swfdec_bits_do_get_gradient (bits, TRUE, FALSE);
}
SwfdecGradient *
swfdec_bits_get_morph_gradient (SwfdecBits * bits)
{
- SwfdecGradient *grad;
- guint i, n_gradients;
-
- n_gradients = swfdec_bits_get_u8 (bits);
- n_gradients *= 2;
- grad = g_malloc (sizeof (SwfdecGradient) +
- sizeof (SwfdecGradientEntry) * (n_gradients - 1));
- for (i = 0; i < n_gradients && swfdec_bits_left (bits); i++) {
- grad->array[i].ratio = swfdec_bits_get_u8 (bits);
- grad->array[i].color = swfdec_bits_get_rgba (bits);
- }
- if (i < n_gradients) {
- SWFDEC_ERROR ("not enough data for %u gradients, could only read %u",
- n_gradients, i);
- }
- grad->n_gradients = i;
- return grad;
+ return swfdec_bits_do_get_gradient (bits, TRUE, TRUE);
}
void
diff-tree ca10e69db70a8396253e0fa2114bd6e3787d61d2 (from 1d7a9186e3cd756bc8f9c9c727dbec0aba0d7e45)
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Sep 17 11:26:46 2007 +0200
remove code dupliction and associated SEGV when reading 0-size RGBA gradients
diff --git a/libswfdec/swfdec_bits.c b/libswfdec/swfdec_bits.c
index 9ec3988..bddef90 100644
--- a/libswfdec/swfdec_bits.c
+++ b/libswfdec/swfdec_bits.c
@@ -598,8 +598,8 @@ swfdec_bits_get_rgba (SwfdecBits * bits)
return SWFDEC_COLOR_COMBINE (r, g, b, a);
}
-SwfdecGradient *
-swfdec_bits_get_gradient (SwfdecBits * bits)
+static inline SwfdecGradient *
+swfdec_bits_do_get_gradient (SwfdecBits *bits, gboolean alpha)
{
SwfdecGradient *grad;
guint i, n_gradients;
@@ -609,7 +609,10 @@ swfdec_bits_get_gradient (SwfdecBits * b
sizeof (SwfdecGradientEntry) * (MAX (n_gradients, 1) - 1));
for (i = 0; i < n_gradients && swfdec_bits_left (bits); i++) {
grad->array[i].ratio = swfdec_bits_get_u8 (bits);
- grad->array[i].color = swfdec_bits_get_color (bits);
+ if (alpha)
+ grad->array[i].color = swfdec_bits_get_rgba (bits);
+ else
+ grad->array[i].color = swfdec_bits_get_color (bits);
}
if (i < n_gradients) {
SWFDEC_ERROR ("not enough data for %u gradients, could only read %u",
@@ -620,24 +623,15 @@ swfdec_bits_get_gradient (SwfdecBits * b
}
SwfdecGradient *
-swfdec_bits_get_gradient_rgba (SwfdecBits * bits)
+swfdec_bits_get_gradient (SwfdecBits * bits)
{
- SwfdecGradient *grad;
- guint i, n_gradients;
+ return swfdec_bits_do_get_gradient (bits, FALSE);
+}
- n_gradients = swfdec_bits_get_u8 (bits);
- grad = g_malloc (sizeof (SwfdecGradient) +
- sizeof (SwfdecGradientEntry) * (n_gradients - 1));
- for (i = 0; i < n_gradients && swfdec_bits_left (bits); i++) {
- grad->array[i].ratio = swfdec_bits_get_u8 (bits);
- grad->array[i].color = swfdec_bits_get_rgba (bits);
- }
- if (i < n_gradients) {
- SWFDEC_ERROR ("not enough data for %u gradients, could only read %u",
- n_gradients, i);
- }
- grad->n_gradients = i;
- return grad;
+SwfdecGradient *
+swfdec_bits_get_gradient_rgba (SwfdecBits * bits)
+{
+ return swfdec_bits_do_get_gradient (bits, TRUE);
}
SwfdecGradient *
More information about the Swfdec
mailing list