Index: gst-libs/gst/riff/riff-media.c
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-base/gst-libs/gst/riff/riff-media.c,v
retrieving revision 1.57
diff -u -r1.57 riff-media.c
--- gst-libs/gst/riff/riff-media.c	8 Mar 2006 09:37:12 -0000	1.57
+++ gst-libs/gst/riff/riff-media.c	9 Mar 2006 20:11:09 -0000
@@ -556,21 +556,23 @@
     else
       num_colors = 256;
 
-    /* palette is always at least 256*4 bytes */
-    copy = gst_buffer_new_and_alloc (MAX (num_colors * 4, 256 * 4));
-    memcpy (GST_BUFFER_DATA (copy), GST_BUFFER_DATA (palette),
-        GST_BUFFER_SIZE (palette));
+    if (GST_BUFFER_SIZE (palette) >= num_colors * 4) {
+      /* palette is always at least 256*4 bytes */
+      copy = gst_buffer_new_and_alloc (MAX (num_colors * 4, 256 * 4));
+      memcpy (GST_BUFFER_DATA (copy), GST_BUFFER_DATA (palette),
+          num_colors * 4);
 
 #if (G_BYTE_ORDER == G_BIG_ENDIAN)
-    gint n;
-    guint32 *data = (guint32 *) GST_BUFFER_DATA (copy);
+      gint n;
+      guint32 *data = (guint32 *) GST_BUFFER_DATA (copy);
 
-    /* own endianness */
-    for (n = 0; n < num_colors; n++)
-      data[n] = GUINT32_FROM_LE (data[n]);
+      /* own endianness */
+      for (n = 0; n < num_colors; n++)
+        data[n] = GUINT32_FROM_LE (data[n]);
 #endif
-    gst_caps_set_simple (caps, "palette_data", GST_TYPE_BUFFER, copy, NULL);
-    gst_buffer_unref (copy);
+      gst_caps_set_simple (caps, "palette_data", GST_TYPE_BUFFER, copy, NULL);
+      gst_buffer_unref (copy);
+    }
   }
 
   return caps;
