premature end of tag detection

DefineMorphShape2 fix
This commit is contained in:
Jindra Petk
2013-04-27 11:32:11 +02:00
parent e479932693
commit 09b7ee71c2
2 changed files with 44 additions and 3 deletions

View File

@@ -0,0 +1,29 @@
/*
* Copyright (C) 2010-2013 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash;
/**
*
* @author JPEXS
*/
public class EndOfStreamException extends RuntimeException {
public EndOfStreamException() {
super("Premature end of the stream reached");
}
}

View File

@@ -185,7 +185,11 @@ public class SWFInputStream extends InputStream {
lastPercent = percent;
}
}
return is.read();
int r = is.read();
if (r == -1) {
throw new EndOfStreamException();
}
return r;
}
/**
@@ -1393,7 +1397,13 @@ public class SWFInputStream extends InputStream {
*/
public Action readAction(ReReadableInputStream rri) throws IOException {
{
int actionCode = readUI8();
int actionCode = -1;
try{
actionCode=readUI8();
}catch(EndOfStreamException eos){
return null;
}
if (actionCode == 0) {
return new ActionEnd();
}
@@ -2576,7 +2586,9 @@ public class SWFInputStream extends InputStream {
*/
public MORPHGRADIENT readMORPHGRADIENT() throws IOException {
MORPHGRADIENT ret = new MORPHGRADIENT();
int numGradients = (int) readUI8();
int numGradients = (int) readUI8();
numGradients = numGradients % 8; //there should be 1 to 8 but sometimes there is more. This modulo seems to be OK.
ret.gradientRecords = new MORPHGRADRECORD[numGradients];
for (int i = 0; i < numGradients; i++) {
ret.gradientRecords[i] = readMORPHGRADRECORD();