| From: | Ranier Vilela <ranier(dot)vf(at)gmail(dot)com> |
|---|---|
| To: | Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Operands don't affect result (CONSTANT_EXPRESSION_RESULT) (src/backend/utils/adt/jsonfuncs.c) |
| Date: | 2021-02-10 23:42:45 |
| Message-ID: | CAEudQAqge3QfzoBRhe59QrB_5g+NmQUj2QpzqZ9Nc7QepXGAEw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
Per Coverity.
The use of type "long" is problematic with Windows 64bits.
Long type on Windows 64bits is 32 bits.
See at:
https://docs.microsoft.com/pt-br/cpp/cpp/data-type-ranges?view=msvc-160
*long* 4 *long int*, *signed long int* -2.147.483.648 a 2.147.483.647
Therefore long never be > INT_MAX at Windows 64 bits.
Thus lindex is always false in this expression:
if (errno != 0 || badp == c || *badp != '\0' || lindex > INT_MAX || lindex
< INT_MIN)
Patch suggestion to fix this.
diff --git a/src/backend/utils/adt/jsonfuncs.c
b/src/backend/utils/adt/jsonfuncs.c
index 215a10f16e..54b0eded76 100644
--- a/src/backend/utils/adt/jsonfuncs.c
+++ b/src/backend/utils/adt/jsonfuncs.c
@@ -1675,7 +1675,7 @@ push_path(JsonbParseState **st, int level, Datum
*path_elems,
* end, the access index must be normalized by level.
*/
enum jbvType *tpath = palloc0((path_len - level) * sizeof(enum jbvType));
- long lindex;
+ int64 lindex;
JsonbValue newkey;
/*
regards,
Ranier Vilela
| Attachment | Content-Type | Size |
|---|---|---|
| jsonfuncs.patch | application/octet-stream | 482 bytes |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alvaro Herrera | 2021-02-10 23:51:47 | Re: PATCH: Batch/pipelining support for libpq |
| Previous Message | Michail Nikolaev | 2021-02-10 23:32:33 | Re: Thoughts on "killed tuples" index hint bits support on standby |