Fix a crash due to buggy user input.

Improve error message.
Reported in
https://gitlab.com/kicad/code/kicad/-/issues/19439#note_2277932762
This commit is contained in:
Holger Vogt 2025-01-01 15:05:14 +01:00
parent 0f5852afdb
commit caa0a7f4a8
2 changed files with 7 additions and 0 deletions

View File

@ -117,6 +117,12 @@ struct pnode* ft_getpnames_quotes(wordlist* wl, bool check)
tmpstr += 2;
/* get the complete zzz of v(zzz) */
char* tpartoken = tmpstr2 = gettok_char(&tmpstr, ')', FALSE, FALSE);
/* Bail out in case of missing closing paren */
if (!tpartoken) {
fprintf(stderr, "Error: Missing ')' in token %s\n", sz);
fprintf(stderr, " Cannot parse the token!\n");
return NULL;
}
/* check if this is v(zzz) or v(xx,yy) */
char* partoken1 = gettok_char(&tpartoken, ',', FALSE, FALSE);
sadd(&ds1, "v(");

View File

@ -469,6 +469,7 @@ com_write(wordlist *wl)
names = ft_getpnames_quotes(&all, TRUE);
if (names == NULL) {
fprintf(stderr, "Error during 'write': no writable vector found.\n");
return;
}