diff options
author | Michael Paquier <michael@paquier.xyz> | 2021-01-07 10:21:02 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2021-01-07 10:21:02 +0900 |
commit | 55fe26a4b580b17d721c5accb842cc6a08295273 (patch) | |
tree | c31011ee3e4a050d0c40bf6c7312e81b7b7a7cac /src/backend/utils/misc/timeout.c | |
parent | 9877374bef76ef03923f6aa8b955f2dbcbe6c2c7 (diff) | |
download | postgresql-55fe26a4b580b17d721c5accb842cc6a08295273.tar.gz postgresql-55fe26a4b580b17d721c5accb842cc6a08295273.zip |
Fix allocation logic of cryptohash context data with OpenSSL
The allocation of the cryptohash context data when building with OpenSSL
was happening in the memory context of the caller of
pg_cryptohash_create(), which could lead to issues with resowner cleanup
if cascading resources are cleaned up on an error. Like other
facilities using resowners, move the base allocation to TopMemoryContext
to ensure a correct cleanup on failure.
The resulting code gets simpler with this commit as the context data is
now hold by a unique opaque pointer, so as there is only one single
allocation done in TopMemoryContext.
After discussion, also change the cryptohash subroutines to return an
error if the caller provides NULL for the context data to ease error
detection on OOM.
Author: Heikki Linnakangas
Discussion: https://postgr.es/m/X9xbuEoiU3dlImfa@paquier.xyz
Diffstat (limited to 'src/backend/utils/misc/timeout.c')
0 files changed, 0 insertions, 0 deletions