Skip to content

Commit 1d80d6b

Browse files
Further reduce dependence on -fwrapv semantics in jsonb.
Commit 108d2ad 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
1 parent aa2d6b1 commit 1d80d6b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/backend/utils/adt/jsonfuncs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ jsonb_array_element_text(PG_FUNCTION_ARGS)
990990
{
991991
uint32 nelements = JB_ROOT_COUNT(jb);
992992

993-
if (-element > nelements)
993+
if (pg_abs_s32(element) > nelements)
994994
PG_RETURN_NULL();
995995
else
996996
element += nelements;
@@ -4811,7 +4811,7 @@ jsonb_delete_idx(PG_FUNCTION_ARGS)
48114811

48124812
if (idx < 0)
48134813
{
4814-
if (-idx > n)
4814+
if (pg_abs_s32(idx) > n)
48154815
idx = n;
48164816
else
48174817
idx = n + idx;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy