Merge pull request #1119 from mariusgreuel/pr-pointer-truncation

Fix pointer truncation for Windows x64
This commit is contained in:
Stefan Rueger 2022-10-11 14:43:41 +01:00 committed by GitHub
commit 929441eb82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -23,6 +23,7 @@
#include <ctype.h> #include <ctype.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <stddef.h> #include <stddef.h>
@ -1083,8 +1084,8 @@ static int cmd_quell(PROGRAMMER *pgm, AVRPART *p, int argc, char *argv[]) {
return 0; return 0;
} }
static int tokenize(char *s, char ***argv) { static int tokenize(char * s, char ***argv) {
int i, n, l, k, nargs, offset; int i, n, l, nargs;
int len, slen; int len, slen;
char *buf; char *buf;
int bufsize; int bufsize;
@ -1145,7 +1146,7 @@ static int tokenize(char *s, char ***argv) {
bufv = bufv_tmp; bufv = bufv_tmp;
nbuf = &buf[l]; nbuf = &buf[l];
/* correct bufv pointers */ /* correct bufv pointers */
k = buf - bufp; ptrdiff_t k = buf - bufp;
for (i=0; i<n; i++) { for (i=0; i<n; i++) {
bufv[i] = bufv[i] + k; bufv[i] = bufv[i] + k;
} }
@ -1166,7 +1167,7 @@ static int tokenize(char *s, char ***argv) {
q = (char *)&av[n+1]; q = (char *)&av[n+1];
memcpy(q, buf, l); memcpy(q, buf, l);
for (i=0; i<n; i++) { for (i=0; i<n; i++) {
offset = bufv[i] - buf; ptrdiff_t offset = bufv[i] - buf;
av[i] = q + offset; av[i] = q + offset;
} }
av[i] = NULL; av[i] = NULL;