mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-02-24 10:44:51 +00:00
Fix sign-extension bug with signed chars in attribute names
This commit is contained in:
parent
a42dbd7968
commit
59faead7fa
16
mbtiles.c
16
mbtiles.c
@ -75,19 +75,25 @@ static void quote(char **buf, const char *s) {
|
|||||||
char *out = tmp;
|
char *out = tmp;
|
||||||
|
|
||||||
for (; *s != '\0'; s++) {
|
for (; *s != '\0'; s++) {
|
||||||
if (*s == '\\' || *s == '\"') {
|
unsigned char ch = (unsigned char) *s;
|
||||||
|
|
||||||
|
if (ch == '\\' || ch == '\"') {
|
||||||
*out++ = '\\';
|
*out++ = '\\';
|
||||||
*out++ = *s;
|
*out++ = ch;
|
||||||
} else if (*s < ' ') {
|
} else if (ch < ' ') {
|
||||||
sprintf(out, "\\u%04x", *s);
|
sprintf(out, "\\u%04x", ch);
|
||||||
out = out + strlen(out);
|
out = out + strlen(out);
|
||||||
} else {
|
} else {
|
||||||
*out++ = *s;
|
*out++ = ch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*out = '\0';
|
*out = '\0';
|
||||||
*buf = realloc(*buf, strlen(*buf) + strlen(tmp) + 1);
|
*buf = realloc(*buf, strlen(*buf) + strlen(tmp) + 1);
|
||||||
|
if (*buf == NULL) {
|
||||||
|
perror("realloc");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
strcat(*buf, tmp);
|
strcat(*buf, tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user