Content-Length: 276007 | pFad | http://github.com/postgrespro/postgres/commit/1d80d6b50e6401828fc445151375f9bde3f99ac6

96 Further reduce dependence on -fwrapv semantics in jsonb. · postgrespro/postgres@1d80d6b · GitHub
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)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/1d80d6b50e6401828fc445151375f9bde3f99ac6

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy