X509_get_pubkey() attempts to decode the public key for certificate x. If successful it returns the public key as an EVP_PKEY pointer with its reference count incremented: this means the returned key must be freed up after use.
X509_get0_pubkey() is similar except it does not increment the reference count of the returned EVP_PKEY so it must not be freed up after use.