Mercurial > hg > sidinfo
changeset 350:c2ebcb0f0d62
Add some more error checking in the STIL parser.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 19 Jan 2020 06:40:40 +0200 |
parents | a6153837c138 |
children | d54112385845 |
files | sidlib.c |
diffstat | 1 files changed, 15 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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