# HG changeset patch # User Matti Hamalainen # Date 1579408840 -7200 # Node ID c2ebcb0f0d62077ba22e88822c596d466ca45442 # Parent a6153837c1384616c7c891fcc1ff5099ab46dcdf Add some more error checking in the STIL parser. diff -r a6153837c138 -r c2ebcb0f0d62 sidlib.c --- a/sidlib.c Sun Jan 19 04:38:29 2020 +0200 +++ b/sidlib.c Sun Jan 19 06:40:40 2020 +0200 @@ -887,10 +887,18 @@ if (ctx.ch == '/') { sidlib_stildb_set_parsemode(&ctx, PM_ENTRY); + entry = NULL; } else if (ctx.ch == '(') { + if (entry == NULL) + { + ret = th_io_error(fh, THERR_INVALID_DATA, + "Unexpected start of subtune indicator without entry."); + goto out; + } + sidlib_stildb_set_parsemode(&ctx, PM_SUBTUNE); ctx.ch = -1; ctx.lineStart = TRUE; @@ -898,6 +906,13 @@ else if (th_isalpha(ctx.ch)) { + if (entry == NULL) + { + ret = th_io_error(fh, THERR_INVALID_DATA, + "Unexpected start of field name without entry."); + goto out; + } + sidlib_stildb_set_parsemode(&ctx, PM_FIELD_NAME); } else