diff options
author | Nathan Bossart <nathan@postgresql.org> | 2024-08-16 15:06:40 -0500 |
---|---|---|
committer | Nathan Bossart <nathan@postgresql.org> | 2024-08-16 15:06:40 -0500 |
commit | 1d80d6b50e6401828fc445151375f9bde3f99ac6 (patch) | |
tree | aecc89ef6dd211959919dad9d2b23d1edce67f33 /src | |
parent | aa2d6b15d6d64564cb5b0d1c1e74fb64b29f41f1 (diff) | |
download | postgresql-1d80d6b50e6401828fc445151375f9bde3f99ac6.tar.gz postgresql-1d80d6b50e6401828fc445151375f9bde3f99ac6.zip |
Further reduce dependence on -fwrapv semantics in jsonb.
Commit 108d2adb9e missed updating a few places in the jsonb code
that rely on signed integer wrapping for correctness. These can
also be fixed by using pg_abs_s32() to negate a signed integer
(that is known to be negative) for comparison with an unsigned
integer.
Reported-by: Alexander Lakhin
Discussion: https://postgr.es/m/bfff906f-300d-81ea-83b7-f2c93845e7f2%40gmail.com
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/utils/adt/jsonfuncs.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/backend/utils/adt/jsonfuncs.c b/src/backend/utils/adt/jsonfuncs.c index 1f8ea51e6ad..62a17a26679 100644 --- a/src/backend/utils/adt/jsonfuncs.c +++ b/src/backend/utils/adt/jsonfuncs.c @@ -990,7 +990,7 @@ jsonb_array_element_text(PG_FUNCTION_ARGS) { uint32 nelements = JB_ROOT_COUNT(jb); - if (-element > nelements) + if (pg_abs_s32(element) > nelements) PG_RETURN_NULL(); else element += nelements; @@ -4811,7 +4811,7 @@ jsonb_delete_idx(PG_FUNCTION_ARGS) if (idx < 0) { - if (-idx > n) + if (pg_abs_s32(idx) > n) idx = n; else idx = n + idx; |