Check -U option for unknown memories during parsing

$ avrdude -qp ATmega2560 -c usbtiny -U flesh:w:blink-mega2560+lext-test.hex:i
avrdude: unknown memory type flesh
avrdude: error parsing update operation 'flesh:w:blink-mega2560+lext-test.hex:i'
This commit is contained in:
Stefan Rueger 2022-08-03 00:04:14 +01:00
parent 42c8169c37
commit 9604a3ef36
3 changed files with 8 additions and 2 deletions

View File

@ -1253,7 +1253,7 @@ void avr_add_mem_order(const char *str) {
exit(1);
}
int avr_known_mem(const char *str) {
int avr_mem_is_known(const char *str) {
for(size_t i=0; i < sizeof avr_mem_order/sizeof *avr_mem_order; i++)
if(avr_mem_order[i] && !strcmp(avr_mem_order[i], str))
return 1;

View File

@ -821,7 +821,7 @@ int avr_put_cycle_count(PROGRAMMER * pgm, AVRPART * p, int cycles);
void avr_add_mem_order(const char *str);
int avr_known_mem(const char *str);
int avr_mem_is_known(const char *str);
#define disable_trailing_ff_removal() avr_mem_hiaddr(NULL)
int avr_mem_hiaddr(AVRMEM * mem);

View File

@ -62,6 +62,12 @@ UPDATE * parse_op(char * s)
return upd;
}
if (!avr_mem_is_known(buf)) {
avrdude_message(MSG_INFO, "%s: unknown memory type %s\n", progname, buf);
free(upd);
return NULL;
}
upd->memtype = (char *)malloc(strlen(buf)+1);
if (upd->memtype == NULL) {
avrdude_message(MSG_INFO, "%s: out of memory\n", progname);