From 3d87ba55fa0824706c8cd2f2fd989e3e97a91325 Mon Sep 17 00:00:00 2001
From: Gary King <gking@iongrid.com>
Date: Wed, 27 Jul 2011 09:47:20 -0700
Subject: [PATCH] hslf: handle invalid picture type terminal condition

the Pictures stream can be terminated by an invalid record
type. HSLFSlideShow wasn't handling this case, instead
often detecting the streams as corrupt.
---
 .../src/org/apache/poi/hslf/HSLFSlideShow.java     |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java b/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java
index 6fb3902..a5fa9b0 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java
@@ -355,6 +355,9 @@ public final class HSLFSlideShow extends POIDocument {
             int imgsize = LittleEndian.getInt(pictstream, pos);
             pos += LittleEndian.INT_SIZE;
 
+            if (!((type == 0xf007) || (type >= 0xf018 && type <= 0xf117)))
+                break;
+
 			// The image size must be 0 or greater
 			// (0 is allowed, but odd, since we do wind on by the header each
 			//  time, so we won't get stuck)
-- 
1.7.3.4

