Merge pull request #1369 from kkujala/master

Remove unreachable logic after error(...) is called.
This commit is contained in:
notmasteryet 2012-03-20 21:24:17 -07:00
commit 8ee818ec03
5 changed files with 32 additions and 42 deletions

View File

@ -570,7 +570,6 @@ var CipherTransformFactory = (function CipherTransformFactoryClosure() {
}; };
} }
error('Unknown crypto method'); error('Unknown crypto method');
return null;
} }
CipherTransformFactory.prototype = { CipherTransformFactory.prototype = {

View File

@ -496,7 +496,10 @@ var FontLoader = {
// Validate the names parameter -- the values can used to construct HTML. // Validate the names parameter -- the values can used to construct HTML.
if (!/^\w+$/.test(names.join(''))) { if (!/^\w+$/.test(names.join(''))) {
error('Invalid font name(s): ' + names.join()); error('Invalid font name(s): ' + names.join());
return; // Keep the return in case if error() did not throw.
// Normally the error-function throws. But if a malicious code
// intercepts the function call then the return is needed.
return;
} }
var div = document.createElement('div'); var div = document.createElement('div');

View File

@ -514,7 +514,6 @@ var XRef = (function XRefClosure() {
return dict; return dict;
// nothing helps // nothing helps
error('Invalid PDF structure'); error('Invalid PDF structure');
return null;
}, },
readXRef: function readXref(startXRef) { readXRef: function readXref(startXRef) {
var stream = this.stream; var stream = this.stream;
@ -723,12 +722,10 @@ var PDFObjects = (function PDFObjectsClosure() {
// If there isn't an object yet or the object isn't resolved, then the // If there isn't an object yet or the object isn't resolved, then the
// data isn't ready yet! // data isn't ready yet!
if (!obj || !obj.isResolved) { if (!obj || !obj.isResolved)
error('Requesting object that isn\'t resolved yet ' + objId); error('Requesting object that isn\'t resolved yet ' + objId);
return null;
} else { return obj.data;
return obj.data;
}
}, },
/** /**

View File

@ -53,15 +53,14 @@ var Parser = (function ParserClosure() {
this.shift(); this.shift();
var dict = new Dict(); var dict = new Dict();
while (!isCmd(this.buf1, '>>') && !isEOF(this.buf1)) { while (!isCmd(this.buf1, '>>') && !isEOF(this.buf1)) {
if (!isName(this.buf1)) { if (!isName(this.buf1))
error('Dictionary key must be a name object'); error('Dictionary key must be a name object');
} else {
var key = this.buf1.name; var key = this.buf1.name;
this.shift(); this.shift();
if (isEOF(this.buf1)) if (isEOF(this.buf1))
break; break;
dict.set(key, this.getObj(cipherTransform)); dict.set(key, this.getObj(cipherTransform));
}
} }
if (isEOF(this.buf1)) if (isEOF(this.buf1))
error('End of file inside dictionary'); error('End of file inside dictionary');
@ -106,15 +105,14 @@ var Parser = (function ParserClosure() {
// parse dictionary // parse dictionary
var dict = new Dict(); var dict = new Dict();
while (!isCmd(this.buf1, 'ID') && !isEOF(this.buf1)) { while (!isCmd(this.buf1, 'ID') && !isEOF(this.buf1)) {
if (!isName(this.buf1)) { if (!isName(this.buf1))
error('Dictionary key must be a name object'); error('Dictionary key must be a name object');
} else {
var key = this.buf1.name; var key = this.buf1.name;
this.shift(); this.shift();
if (isEOF(this.buf1)) if (isEOF(this.buf1))
break; break;
dict.set(key, this.getObj(cipherTransform)); dict.set(key, this.getObj(cipherTransform));
}
} }
// parse image stream // parse image stream
@ -176,10 +174,8 @@ var Parser = (function ParserClosure() {
// get length // get length
var length = this.fetchIfRef(dict.get('Length')); var length = this.fetchIfRef(dict.get('Length'));
if (!isInt(length)) { if (!isInt(length))
error('Bad ' + length + ' attribute in stream'); error('Bad ' + length + ' attribute in stream');
length = 0;
}
// skip over the stream data // skip over the stream data
stream.pos = pos + length; stream.pos = pos + length;
@ -208,14 +204,13 @@ var Parser = (function ParserClosure() {
filter = filterArray[i]; filter = filterArray[i];
if (!isName(filter)) if (!isName(filter))
error('Bad filter name: ' + filter); error('Bad filter name: ' + filter);
else {
params = null; params = null;
if (isArray(paramsArray) && (i in paramsArray)) if (isArray(paramsArray) && (i in paramsArray))
params = paramsArray[i]; params = paramsArray[i];
stream = this.makeFilter(stream, filter.name, length, params); stream = this.makeFilter(stream, filter.name, length, params);
// after the first stream the length variable is invalid // after the first stream the length variable is invalid
length = null; length = null;
}
} }
} }
return stream; return stream;
@ -527,17 +522,15 @@ var Lexer = (function LexerClosure() {
// fall through // fall through
case ')': case ')':
error('Illegal character: ' + ch); error('Illegal character: ' + ch);
return Error;
} }
// command // command
var str = ch; var str = ch;
while (!!(ch = stream.lookChar()) && !specialChars[ch.charCodeAt(0)]) { while (!!(ch = stream.lookChar()) && !specialChars[ch.charCodeAt(0)]) {
stream.skip(); stream.skip();
if (str.length == 128) { if (str.length == 128)
error('Command token too long: ' + str.length); error('Command token too long: ' + str.length);
break;
}
str += ch; str += ch;
} }
if (str == 'true') if (str == 'true')
@ -594,7 +587,6 @@ var Linearization = (function LinearizationClosure() {
return obj; return obj;
} }
error('"' + name + '" field in linearization table is invalid'); error('"' + name + '" field in linearization table is invalid');
return 0;
}, },
getHint: function linearizationGetHint(index) { getHint: function linearizationGetHint(index) {
var linDict = this.linDict; var linDict = this.linDict;
@ -607,7 +599,6 @@ var Linearization = (function LinearizationClosure() {
return obj2; return obj2;
} }
error('Hints table in linearization table is invalid: ' + index); error('Hints table in linearization table is invalid: ' + index);
return 0;
}, },
get length() { get length() {
if (!isDict(this.linDict)) if (!isDict(this.linDict))

View File

@ -82,7 +82,7 @@ Shadings.RadialAxial = (function RadialAxialClosure() {
fnObj = xref.fetchIfRef(fnObj); fnObj = xref.fetchIfRef(fnObj);
if (isArray(fnObj)) if (isArray(fnObj))
error('No support for array of functions'); error('No support for array of functions');
else if (!isPDFFunction(fnObj)) if (!isPDFFunction(fnObj))
error('Invalid function'); error('Invalid function');
var fn = PDFFunction.parse(xref, fnObj); var fn = PDFFunction.parse(xref, fnObj);