Index out of range error in Slide.GetThumbnail method... Bug?

Hi… Please see the code below and the error I received. I have also attached the PowerPoint document that caused the error. Please tell if I am doing something wrong here or If there is a bug that I found. I call this function (CreatePPtThumbnail) in a for loop like this:
My Code:
// Start
foreach (Slide slide in pres.Slides)
{
if (slide != null && !slide.IsMasterSlide)
{
CreatePPtThumbnail(slide);
}
}


public void CreatePPtThumbnail(Slide slide)
{
string fileName = this.PptThumbPath + slide.SlidePosition + “.png”;
//Getting the thumbnail image of the slide at specified size
System.Drawing.Image thumbImage = slide.GetThumbnail(this.thumbNailSize);
thumbImage.Save(fileName, this.ImgCodecInfo, this.EncoderParams);
}
// End

Error I got:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index at System.Collections.ArrayList.get_Item(Int32 index)
at Aspose.Slides.PictureBullets.get_Item(Int32 index)
at p8.a(Boolean A_0)
at p8…ctor(Graphics A_0, Presentation A_1, Paragraphs A_2, od A_3, Single A_4, Boolean A_5, AnchorText A_6, Tabs A_7, Links A_8, Color A_9)
at Aspose.Slides.TextFrame.b()
at Aspose.Slides.TextFrame.Draw(Image img, Matrix lastTransform, IDrawingControl drawingControl, ArrayList ancestors, ArrayList rotations, HeaderFooter headerFooter, Int32 slideNumber)
at Aspose.Slides.Rectangle.Draw(Image img, Matrix lastTransform, IDrawingControl drawingControl, ArrayList ancestors, ArrayList rotations, HeaderFooter headerFooter, Int32 slideNumber)
at Aspose.Slides.Slide.GetThumbnail(Size imageSize, Rectangle window, IDrawingControl drawingControl)
at Aspose.Slides.Slide.GetThumbnail(Size imageSize)
at PPTImportService.Preview.CreatePPtThumbnail(Slide slide) in C:\MyDocs\Projects\PPTImportService\PPTImportService\Preview.aspx.cs:line 161
at PPTImportService.Preview.AnalyzePpt(Object sender, ProgressTaskEventArgs pBar) in C:\MyDocs\Projects\PPTImportService\PPTImportService\Preview.aspx.cs:line 113


Dear Aseem,

The presentation internal structure is broken. We will investigate and try to find any workaround if possible.

FYI: If you open presentation and save it back with Save As… menu command, it will fix the presentation. As you can see the images generated after fixing the presentation.

Anyway, the correct code should have such a loop.

// Start
for (int i = 1; i <= pres.Slides.LastSlidePosition; i++)
{
    Slide slide = pres.GetSlideByPosition(i);
    if (slide != null && !slide.IsMasterSlide)
    {
        CreatePPtThumbnail(slide);
    }
}


Please tell how is this:
for(int i=1; i<=pres.Slides.LastSlidePosition; i++)
better than this:
foreach (Slide slide in pres.Slides)

Thanks.

Because Presentation.Slides not only contains normal slides but also title masters.

Suppose your presentation contains

2- Slide Masters (found in Presentation.Masters)

2- Title Masters (found in Presentation.Slides)

6- Normal Slides (found in Presentation.Slides)

Then foreach loop will run 8 times = Title Masters + Normal Slides

But LastSlidePosition loop will run 6 times = Normal Slides only