Mercurial > hg > sidinfo
comparison sidlib.c @ 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 | 629876cc0540 |
children | 4978ff445572 |
comparison
equal
deleted
inserted
replaced
349:a6153837c138 | 350:c2ebcb0f0d62 |
---|---|
885 // PM_IDLE | 885 // PM_IDLE |
886 strPos = 0; | 886 strPos = 0; |
887 if (ctx.ch == '/') | 887 if (ctx.ch == '/') |
888 { | 888 { |
889 sidlib_stildb_set_parsemode(&ctx, PM_ENTRY); | 889 sidlib_stildb_set_parsemode(&ctx, PM_ENTRY); |
890 entry = NULL; | |
890 } | 891 } |
891 else | 892 else |
892 if (ctx.ch == '(') | 893 if (ctx.ch == '(') |
893 { | 894 { |
895 if (entry == NULL) | |
896 { | |
897 ret = th_io_error(fh, THERR_INVALID_DATA, | |
898 "Unexpected start of subtune indicator without entry."); | |
899 goto out; | |
900 } | |
901 | |
894 sidlib_stildb_set_parsemode(&ctx, PM_SUBTUNE); | 902 sidlib_stildb_set_parsemode(&ctx, PM_SUBTUNE); |
895 ctx.ch = -1; | 903 ctx.ch = -1; |
896 ctx.lineStart = TRUE; | 904 ctx.lineStart = TRUE; |
897 } | 905 } |
898 else | 906 else |
899 if (th_isalpha(ctx.ch)) | 907 if (th_isalpha(ctx.ch)) |
900 { | 908 { |
909 if (entry == NULL) | |
910 { | |
911 ret = th_io_error(fh, THERR_INVALID_DATA, | |
912 "Unexpected start of field name without entry."); | |
913 goto out; | |
914 } | |
915 | |
901 sidlib_stildb_set_parsemode(&ctx, PM_FIELD_NAME); | 916 sidlib_stildb_set_parsemode(&ctx, PM_FIELD_NAME); |
902 } | 917 } |
903 else | 918 else |
904 { | 919 { |
905 // Error! Invalid character found | 920 // Error! Invalid character found |