Report incomplete graphics commands as parser errors

This commit is contained in:
Kovid Goyal
2017-09-26 11:15:46 +05:30
parent 83de392b39
commit 56c2e0c26a
2 changed files with 33 additions and 17 deletions

View File

@@ -591,7 +591,7 @@ parse_graphics_code(Screen *screen, PyObject UNUSED *dump_callback) {
case FLAG:
switch(key) {
#define F(a) case a: g.a = screen->parser_buf[pos++]; break
#define F(a) case a: g.a = screen->parser_buf[pos++] & 0xff; break
F(action); F(transmission_type);
default:
break;
@@ -653,6 +653,17 @@ parse_graphics_code(Screen *screen, PyObject UNUSED *dump_callback) {
break;
}
}
switch(state) {
case EQUAL:
REPORT_ERROR("Malformed graphics control block, no = after key"); return;
case INT:
case UINT:
REPORT_ERROR("Malformed graphics control block, expecting an integer value"); return;
case FLAG:
REPORT_ERROR("Malformed graphics control block, expecting a flag value"); return;
default:
break;
}
#define A(x) #x, g.x
#define U(x) #x, (unsigned int)(g.x)
#define I(x) #x, (int)(g.x)