]> git.ipfire.org Git - thirdparty/openssl.git/commit
crypto/x509/pcy_tree.c: fix leak of tree in X509_policy_check()
authorhuanghuihui0904 <625173@qq.com>
Mon, 16 Mar 2026 03:05:36 +0000 (11:05 +0800)
committerTomas Mraz <tomas@openssl.foundation>
Fri, 3 Apr 2026 15:04:16 +0000 (17:04 +0200)
commit99cde10ca9b5a7273227b62035bcc163e26593a9
tree629ad9b49aa8675799f7043a839f589c4d3f2657
parent1b06f74e7398a088e448fbe7f3df8d18e41430ef
crypto/x509/pcy_tree.c: fix leak of tree in X509_policy_check()

When init_ret indicates both X509_PCY_TREE_EXPLICIT and X509_PCY_TREE_EMPTY,
the function returns without freeing the initialized policy tree.
Free the tree before returning, consistent with the earlier TREE_EMPTY branch.

Also defer *ptree = tree assignment and free the tree when user policies
are empty to avoid returning invalid memory.

Fixes #30435

Signed-off-by: huanghuihui0904 <625173@qq.com>
Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Fri Apr  3 15:03:37 2026
(Merged from https://github.com/openssl/openssl/pull/30436)

(cherry picked from commit c3d24d9121ef12d8b1f2615e7655e07b5a624358)
crypto/x509/pcy_tree.c