mirror of
https://github.com/json-c/json-c.git
synced 2026-04-07 22:39:08 +08:00
Merge pull request #694 from ihsinme/patch-1
fix invalid unsigned arithmetic.
This commit is contained in:
@@ -235,7 +235,7 @@ static int json_escape_str(struct printbuf *pb, const char *str, size_t len, int
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pos - start_offset > 0)
|
if (pos > start_offset)
|
||||||
printbuf_memappend(pb, str + start_offset, pos - start_offset);
|
printbuf_memappend(pb, str + start_offset, pos - start_offset);
|
||||||
|
|
||||||
if (c == '\b')
|
if (c == '\b')
|
||||||
@@ -261,7 +261,7 @@ static int json_escape_str(struct printbuf *pb, const char *str, size_t len, int
|
|||||||
if (c < ' ')
|
if (c < ' ')
|
||||||
{
|
{
|
||||||
char sbuf[7];
|
char sbuf[7];
|
||||||
if (pos - start_offset > 0)
|
if (pos > start_offset)
|
||||||
printbuf_memappend(pb, str + start_offset,
|
printbuf_memappend(pb, str + start_offset,
|
||||||
pos - start_offset);
|
pos - start_offset);
|
||||||
snprintf(sbuf, sizeof(sbuf), "\\u00%c%c", json_hex_chars[c >> 4],
|
snprintf(sbuf, sizeof(sbuf), "\\u00%c%c", json_hex_chars[c >> 4],
|
||||||
@@ -273,7 +273,7 @@ static int json_escape_str(struct printbuf *pb, const char *str, size_t len, int
|
|||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pos - start_offset > 0)
|
if (pos > start_offset)
|
||||||
printbuf_memappend(pb, str + start_offset, pos - start_offset);
|
printbuf_memappend(pb, str + start_offset, pos - start_offset);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user