Use 'snprintf' instead of 'sprintf'
This gets rid of a linker warning when compiling on OpenBSD:
./.libs/libjq.a(jv_print.o)(.text+0x2fc): In function `jvp_dump_string':
/root/jq-1.5/jv_print.c:118: warning: sprintf() is often misused, please use snprintf()
This commit is contained in:
1 parent
7032228879
commit
5d23c240b6
1 file changed
+2
-2
+2
-2
@@ -115,10 +115,10 @@ static void jvp_dump_string(jv str, int ascii_only, FILE* F, jv* S, int T) {
|
||||
}
|
||||
if (unicode_escape) {
|
||||
if (c <= 0xffff) {
|
||||
sprintf(buf, "\\u%04x", c);
|
||||
snprintf(buf, sizeof(buf), "\\u%04x", c);
|
||||
} else {
|
||||
c -= 0x10000;
|
||||
sprintf(buf, "\\u%04x\\u%04x",
|
||||
snprintf(buf, sizeof(buf), "\\u%04x\\u%04x",
|
||||
0xD800 | ((c & 0xffc00) >> 10),
|
||||
0xDC00 | (c & 0x003ff));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user