mirror of
https://github.com/mariusgreuel/avrdude.git
synced 2025-12-15 02:01:07 +00:00
Submitted by Jon Thacker:
patch #9253: Fix for giving terminal_mode commands more than 20 arguments * term.c (tokenize): fix realloc usage, pointer returned not necessarily the same as pointer passed git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1471 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
9
term.c
9
term.c
@@ -780,11 +780,12 @@ static int cmd_verbose(PROGRAMMER * pgm, struct avrpart * p,
|
||||
|
||||
static int tokenize(char * s, char *** argv)
|
||||
{
|
||||
int i, n, l, nargs, offset;
|
||||
int i, n, l, k, nargs, offset;
|
||||
int len, slen;
|
||||
char * buf;
|
||||
int bufsize;
|
||||
char ** bufv;
|
||||
char * bufp;
|
||||
char * q, * r;
|
||||
char * nbuf;
|
||||
char ** av;
|
||||
@@ -821,9 +822,15 @@ static int tokenize(char * s, char *** argv)
|
||||
/* realloc space for another 20 args */
|
||||
bufsize += 20;
|
||||
nargs += 20;
|
||||
bufp = buf;
|
||||
buf = realloc(buf, bufsize);
|
||||
bufv = realloc(bufv, nargs*sizeof(char *));
|
||||
nbuf = &buf[l];
|
||||
/* correct bufv pointers */
|
||||
k = buf - bufp;
|
||||
for (i=0; i<n; i++) {
|
||||
bufv[i] = bufv[i] + k;
|
||||
}
|
||||
for (i=n; i<nargs; i++)
|
||||
bufv[i] = NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user