Browse Source

Fix a crash due to buggy user input.

Improve error message.
Reported in
https://gitlab.com/kicad/code/kicad/-/issues/19439#note_2277932762
pre-master-46
Holger Vogt 1 year ago
parent
commit
1b7c8eb2d7
  1. 6
      src/frontend/parse.c
  2. 1
      src/frontend/postcoms.c

6
src/frontend/parse.c

@ -117,6 +117,12 @@ struct pnode* ft_getpnames_quotes(wordlist* wl, bool check)
tmpstr += 2; tmpstr += 2;
/* get the complete zzz of v(zzz) */ /* get the complete zzz of v(zzz) */
char* tpartoken = tmpstr2 = gettok_char(&tmpstr, ')', FALSE, FALSE); 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) */ /* check if this is v(zzz) or v(xx,yy) */
char* partoken1 = gettok_char(&tpartoken, ',', FALSE, FALSE); char* partoken1 = gettok_char(&tpartoken, ',', FALSE, FALSE);
sadd(&ds1, "v("); sadd(&ds1, "v(");

1
src/frontend/postcoms.c

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

Loading…
Cancel
Save