Remove dependency to system calls for memory allocation in refint

Michael Paquier <michael@paquier.xyz>

Commit: b0b6196386681383b8f0cb76df4fd35178a7371e
Author: Michael Paquier <michael@paquier.xyz>
Date: 2020-01-08T01:02:55Z
Releases: 13.0
Remove dependency to system calls for memory allocation in refint

Failures in allocations could lead to crashes with NULL pointer
dereferences .  Memory context TopMemoryContext is used instead to keep
alive the plans allocated in the session.  A more specific context could
be used here, but this is left for later.

Reported-by: Jian Zhang
Author: Michael Paquier
Reviewed-by: Tom Lane, Andres Freund
Discussion: https://postgr.es/m/16190-70181c803641c3dc@postgresql.org

Files

PathChange+/−
contrib/spi/refint.c modified +20 −6

Discussion