Skip to content

Commit

Permalink
[yugabyte#11236] ysql: Apply non-zero offset after checking against N…
Browse files Browse the repository at this point in the history
…ULL pointer

Summary:
In ASAN test run, we can see the following:
```
ts1|pid72520|:24791 ../../../../../src/postgres/contrib/pg_trgm/trgm_gist.c:691:40: runtime error: applying non-zero offset 16 to null pointer
ts1|pid72520|:24791     #0 0x7f876a014577 in gtrgm_penalty /nfusr/alma8-gcp-cloud/jenkins-worker-r0jtg3/jenkins/jenkins-github-yugabyte-db-phabricator-158083/src/postgres/contrib/pg_trgm/../../../../../src/postgres/contrib/pg_trgm/trgm_gist.c:691:40
ts1|pid72520|:24791     #1 0x13d8ae5 in FunctionCall3Coll /nfusr/alma8-gcp-cloud/jenkins-worker-r0jtg3/jenkins/jenkins-github-yugabyte-db-phabricator-158083/src/postgres/src/backend/utils/fmgr/../../../../../../../src/postgres/src/backend/utils/fmgr/fmgr.c:1182:11
```

This revision delays the application of non-zero offset after checking that cache is not NULL.

Test Plan: mvn test -Dtest=org.yb.pgsql.TestPgRegressContribPgTrgm

Reviewers: amartsinchyk, myang

Reviewed By: myang

Subscribers: yql

Differential Revision: https://phabricator.dev.yugabyte.com/D15021
  • Loading branch information
tedyu committed Feb 16, 2022
1 parent 3200786 commit f8bacaf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/postgres/contrib/pg_trgm/trgm_gist.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ gtrgm_penalty(PG_FUNCTION_ARGS)
if (ISARRKEY(newval))
{
char *cache = (char *) fcinfo->flinfo->fn_extra;
TRGM *cachedVal = (TRGM *) (cache + MAXALIGN(sizeof(BITVEC)));
TRGM *cachedVal = cache ? (TRGM *) (cache + MAXALIGN(sizeof(BITVEC))) : NULL;
Size newvalsize = VARSIZE(newval);
BITVECP sign;

Expand Down

0 comments on commit f8bacaf

Please sign in to comment.