aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/json.c
diff options
context:
space:
mode:
authorNoah Misch <noah@leadboat.com>2014-07-06 00:29:51 -0400
committerNoah Misch <noah@leadboat.com>2014-07-06 00:29:51 -0400
commit333b7db8b39679acf0665b3fc4ad99cbc14fbba7 (patch)
tree07fadd4734a73a7ad4129b9076ce405586909af4 /src/backend/utils/adt/json.c
parente254ff21d1286fe5c2b5ecdfa9bb6b15a7830fcd (diff)
downloadpostgresql-333b7db8b39679acf0665b3fc4ad99cbc14fbba7.tar.gz
postgresql-333b7db8b39679acf0665b3fc4ad99cbc14fbba7.zip
Consistently pass an "unsigned char" to ctype.h functions.
The isxdigit() calls relied on undefined behavior. The isascii() call was well-defined, but our prevailing style is to include the cast. Back-patch to 9.4, where the isxdigit() calls were introduced.
Diffstat (limited to 'src/backend/utils/adt/json.c')
-rw-r--r--src/backend/utils/adt/json.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/backend/utils/adt/json.c b/src/backend/utils/adt/json.c
index 841dd1aeae2..bc0c602fa3e 100644
--- a/src/backend/utils/adt/json.c
+++ b/src/backend/utils/adt/json.c
@@ -2353,8 +2353,11 @@ escape_json(StringInfo buf, const char *str)
* only unicode escape that should be present is \u0000,
* all the other unicode escapes will have been resolved.
*/
- if (p[1] == 'u' && isxdigit(p[2]) && isxdigit(p[3])
- && isxdigit(p[4]) && isxdigit(p[5]))
+ if (p[1] == 'u' &&
+ isxdigit((unsigned char) p[2]) &&
+ isxdigit((unsigned char) p[3]) &&
+ isxdigit((unsigned char) p[4]) &&
+ isxdigit((unsigned char) p[5]))
appendStringInfoCharMacro(buf, *p);
else
appendStringInfoString(buf, "\\\\");