mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +00:00
Return false on invalid input in Font::fromString()
Fixes crash with invalid font-update lfun
(cherry picked from commit 2a9648fc4c
)
This commit is contained in:
parent
e01397f1db
commit
5a69b8a184
12
src/Font.cpp
12
src/Font.cpp
@ -695,18 +695,26 @@ bool Font::fromString(string const & data, bool & toggle)
|
|||||||
|
|
||||||
if (token == "family") {
|
if (token == "family") {
|
||||||
int const next = lex.getInteger();
|
int const next = lex.getInteger();
|
||||||
|
if (next == -1)
|
||||||
|
return false;
|
||||||
bits_.setFamily(FontFamily(next));
|
bits_.setFamily(FontFamily(next));
|
||||||
|
|
||||||
} else if (token == "series") {
|
} else if (token == "series") {
|
||||||
int const next = lex.getInteger();
|
int const next = lex.getInteger();
|
||||||
|
if (next == -1)
|
||||||
|
return false;
|
||||||
bits_.setSeries(FontSeries(next));
|
bits_.setSeries(FontSeries(next));
|
||||||
|
|
||||||
} else if (token == "shape") {
|
} else if (token == "shape") {
|
||||||
int const next = lex.getInteger();
|
int const next = lex.getInteger();
|
||||||
|
if (next == -1)
|
||||||
|
return false;
|
||||||
bits_.setShape(FontShape(next));
|
bits_.setShape(FontShape(next));
|
||||||
|
|
||||||
} else if (token == "size") {
|
} else if (token == "size") {
|
||||||
int const next = lex.getInteger();
|
int const next = lex.getInteger();
|
||||||
|
if (next == -1)
|
||||||
|
return false;
|
||||||
bits_.setSize(FontSize(next));
|
bits_.setSize(FontSize(next));
|
||||||
// FIXME: shall style be handled there? Probably not.
|
// FIXME: shall style be handled there? Probably not.
|
||||||
} else if (token == "emph" || token == "underbar"
|
} else if (token == "emph" || token == "underbar"
|
||||||
@ -716,6 +724,8 @@ bool Font::fromString(string const & data, bool & toggle)
|
|||||||
|| token == "nospellcheck") {
|
|| token == "nospellcheck") {
|
||||||
|
|
||||||
int const next = lex.getInteger();
|
int const next = lex.getInteger();
|
||||||
|
if (next == -1)
|
||||||
|
return false;
|
||||||
FontState const misc = FontState(next);
|
FontState const misc = FontState(next);
|
||||||
|
|
||||||
if (token == "emph")
|
if (token == "emph")
|
||||||
@ -739,6 +749,8 @@ bool Font::fromString(string const & data, bool & toggle)
|
|||||||
|
|
||||||
} else if (token == "color") {
|
} else if (token == "color") {
|
||||||
int const next = lex.getInteger();
|
int const next = lex.getInteger();
|
||||||
|
if (next == -1)
|
||||||
|
return false;
|
||||||
bits_.setColor(ColorCode(next));
|
bits_.setColor(ColorCode(next));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5988,7 +5988,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
toggleAndShow(cur, this, font, toggleall);
|
toggleAndShow(cur, this, font, toggleall);
|
||||||
cur.message(bformat(_("Text properties applied: %1$s"), props));
|
cur.message(bformat(_("Text properties applied: %1$s"), props));
|
||||||
} else
|
} else
|
||||||
LYXERR0("Invalid argument of textstyle-update");
|
cur.message(_("Invalid argument of textstyle-update"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user