Ensure page_size is always at least 1
This avoids potential divisions by 0, and possibly also other mistakes in case of malformed avrdude.conf entries. The solution is different than the one in patch #9820 but is supposed to cover that condition as well. patch #9820: Fix some out-of-bounds/uninitialized issues git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1436 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
parent
785b0cea55
commit
da0e437eaa
|
@ -254,6 +254,7 @@ AVRMEM * avr_new_memtype(void)
|
|||
}
|
||||
|
||||
memset(m, 0, sizeof(*m));
|
||||
m->page_size = 1; // ensure not 0
|
||||
|
||||
return m;
|
||||
}
|
||||
|
|
|
@ -1310,7 +1310,13 @@ mem_spec :
|
|||
|
||||
K_PAGE_SIZE TKN_EQUAL TKN_NUMBER
|
||||
{
|
||||
current_mem->page_size = $3->value.number;
|
||||
int ps = $3->value.number;
|
||||
if (ps <= 0)
|
||||
avrdude_message(MSG_INFO,
|
||||
"%s, line %d: invalid page size %d, ignored\n",
|
||||
infile, lineno, ps);
|
||||
else
|
||||
current_mem->page_size = ps;
|
||||
free_token($3);
|
||||
} |
|
||||
|
||||
|
|
Loading…
Reference in New Issue