mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +03:00
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
This commit is contained in:
@ -990,7 +990,7 @@ jsonb_array_element_text(PG_FUNCTION_ARGS)
|
|||||||
{
|
{
|
||||||
uint32 nelements = JB_ROOT_COUNT(jb);
|
uint32 nelements = JB_ROOT_COUNT(jb);
|
||||||
|
|
||||||
if (-element > nelements)
|
if (pg_abs_s32(element) > nelements)
|
||||||
PG_RETURN_NULL();
|
PG_RETURN_NULL();
|
||||||
else
|
else
|
||||||
element += nelements;
|
element += nelements;
|
||||||
@ -4811,7 +4811,7 @@ jsonb_delete_idx(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
if (idx < 0)
|
if (idx < 0)
|
||||||
{
|
{
|
||||||
if (-idx > n)
|
if (pg_abs_s32(idx) > n)
|
||||||
idx = n;
|
idx = n;
|
||||||
else
|
else
|
||||||
idx = n + idx;
|
idx = n + idx;
|
||||||
|
Reference in New Issue
Block a user