summaryrefslogtreecommitdiffstats
path: root/crypto/x509v3/pcy_tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/x509v3/pcy_tree.c')
-rw-r--r--crypto/x509v3/pcy_tree.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/crypto/x509v3/pcy_tree.c b/crypto/x509v3/pcy_tree.c
index 6c7fd35405..3c504e82c6 100644
--- a/crypto/x509v3/pcy_tree.c
+++ b/crypto/x509v3/pcy_tree.c
@@ -25,6 +25,8 @@
# define OPENSSL_POLICY_TREE_NODES_MAX 1000
#endif
+static void exnode_free(X509_POLICY_NODE *node);
+
/*
* Enable this to print out the complete policy tree at various point during
* evaluation.
@@ -572,15 +574,24 @@ static int tree_calculate_user_set(X509_POLICY_TREE *tree,
extra->qualifier_set = anyPolicy->data->qualifier_set;
extra->flags = POLICY_DATA_FLAG_SHARED_QUALIFIERS
| POLICY_DATA_FLAG_EXTRA_NODE;
- node = level_add_node(NULL, extra, anyPolicy->parent, tree, 1);
+ node = level_add_node(NULL, extra, anyPolicy->parent,
+ tree, 1);
+ if (node == NULL) {
+ policy_data_free(extra);
+ return 0;
+ }
}
if (!tree->user_policies) {
tree->user_policies = sk_X509_POLICY_NODE_new_null();
- if (!tree->user_policies)
- return 1;
+ if (!tree->user_policies) {
+ exnode_free(node);
+ return 0;
+ }
}
- if (!sk_X509_POLICY_NODE_push(tree->user_policies, node))
+ if (!sk_X509_POLICY_NODE_push(tree->user_policies, node)) {
+ exnode_free(node);
return 0;
+ }
}
return 1;
}