diff --git a/include/pear/Mail/mimeDecode.php b/include/pear/Mail/mimeDecode.php
index fd1fdba0720575aaecad82934bb542dcd6f5dd25..29095c9605e270af4b885ad0181a1dcd1ab6800f 100644
--- a/include/pear/Mail/mimeDecode.php
+++ b/include/pear/Mail/mimeDecode.php
@@ -529,6 +529,15 @@ class Mail_mimeDecode extends PEAR
         if ($input instanceof StringView) {
             $parts = $input->split('--' . $boundary);
             array_shift($parts);
+
+            if (count($parts) > 0
+                && $parts[count($parts)-1]->substr(0, 2)->__toString() == '--'
+            ) {
+                // Drop the last part if it starts with '--' as such would
+                // be past the end of a multipart section
+                array_pop($parts);
+            }
+
             return $parts;
         }