diff --git a/gst/asfdemux/asfpacket.c b/gst/asfdemux/asfpacket.c
index 08726fa..f96bd7d 100644
--- a/gst/asfdemux/asfpacket.c
+++ b/gst/asfdemux/asfpacket.c
@@ -457,6 +457,7 @@ gst_asf_demux_parse_packet (GstASFDemux * demux, GstBuffer * buf)
   gboolean ret = TRUE;
   guint8 ec_flags, flags1;
   guint size;
+  gboolean padding_isset;
 
   data = GST_BUFFER_DATA (buf);
   size = GST_BUFFER_SIZE (buf);
@@ -506,6 +507,7 @@ gst_asf_demux_parse_packet (GstASFDemux * demux, GstBuffer * buf)
   packet.sequence = asf_packet_read_varlen_int (flags1, 1, &data, &size);
 
   packet.padding = asf_packet_read_varlen_int (flags1, 3, &data, &size);
+  padding_isset = (flags1 >> 3) & 0x03;
 
   if (G_UNLIKELY (size < 6))
     goto short_packet;
@@ -529,11 +531,15 @@ gst_asf_demux_parse_packet (GstASFDemux * demux, GstBuffer * buf)
   if (G_UNLIKELY (packet.padding == (guint) - 1 || size < packet.padding))
     goto short_packet;
 
-  size -= packet.padding;
-
   /* adjust available size for parsing if there's less actual packet data for
    * parsing than there is data in bytes (for sample see bug 431318) */
-  if (G_UNLIKELY (packet.length != 0 && packet.length < demux->packet_size)) {
+  if (padding_isset) {
+    size -= packet.padding;
+    if (G_UNLIKELY (packet.length != 0 && 
+                   (packet.length + packet.padding) < demux->packet_size)) {
+      GST_LOG_OBJECT (demux, "packet.length + packet.padding < demux->packet_size");
+    }
+  } else if (G_UNLIKELY (packet.length != 0 && packet.length < demux->packet_size)) {
     GST_LOG_OBJECT (demux, "shortened packet, adjusting available data size");
     if (size < demux->packet_size - packet.length)
       goto short_packet;
