Only accept non-negative lyxscale parameters

Since lyxscale is unsigned, a negative value would lead to a very
large positive value.

Spotted by coverity.
This commit is contained in:
Jean-Marc Lasgouttes 2017-03-13 18:16:27 +01:00
parent 50060053e3
commit 7d4b8b7606

View File

@ -296,10 +296,16 @@ bool InsetExternalParams::read(Buffer const & buffer, Lexer & lex)
break;
}
case EX_LYXSCALE:
case EX_LYXSCALE: {
lex.next();
lyxscale = lex.getInteger();
int const ls = lex.getInteger();
// negative values are not accepted.
if (ls >= 0)
lyxscale = ls;
else
lex.printError("ExternalInset::read: Wrong lyxscale: $$Token");
break;
}
case EX_DRAFT:
draft = true;
@ -379,8 +385,6 @@ bool InsetExternalParams::read(Buffer const & buffer, Lexer & lex)
if (lyxerr.debugging(Debug::EXTERNAL)) {
lyxerr << "InsetExternalParams::read:\n";
// false positive
// coverity[NEGATIVE_RETURNS]
write(buffer, lyxerr);
}