OLD | NEW |
1 /* tasn_fre.c */ | 1 /* tasn_fre.c */ |
2 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
3 * project 2000. | 3 * project 2000. |
4 */ | 4 */ |
5 /* ==================================================================== | 5 /* ==================================================================== |
6 * Copyright (c) 2000 The OpenSSL Project. All rights reserved. | 6 * Copyright (c) 2000 The OpenSSL Project. All rights reserved. |
7 * | 7 * |
8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
10 * are met: | 10 * are met: |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 ASN1_primitive_free(pval, it); | 103 ASN1_primitive_free(pval, it); |
104 break; | 104 break; |
105 | 105 |
106 case ASN1_ITYPE_MSTRING: | 106 case ASN1_ITYPE_MSTRING: |
107 ASN1_primitive_free(pval, it); | 107 ASN1_primitive_free(pval, it); |
108 break; | 108 break; |
109 | 109 |
110 case ASN1_ITYPE_CHOICE: | 110 case ASN1_ITYPE_CHOICE: |
111 if (asn1_cb) | 111 if (asn1_cb) |
112 { | 112 { |
113 » » » i = asn1_cb(ASN1_OP_FREE_PRE, pval, it); | 113 » » » i = asn1_cb(ASN1_OP_FREE_PRE, pval, it, NULL); |
114 if (i == 2) | 114 if (i == 2) |
115 return; | 115 return; |
116 } | 116 } |
117 i = asn1_get_choice_selector(pval, it); | 117 i = asn1_get_choice_selector(pval, it); |
118 if ((i >= 0) && (i < it->tcount)) | 118 if ((i >= 0) && (i < it->tcount)) |
119 { | 119 { |
120 ASN1_VALUE **pchval; | 120 ASN1_VALUE **pchval; |
121 tt = it->templates + i; | 121 tt = it->templates + i; |
122 pchval = asn1_get_field_ptr(pval, tt); | 122 pchval = asn1_get_field_ptr(pval, tt); |
123 ASN1_template_free(pchval, tt); | 123 ASN1_template_free(pchval, tt); |
124 } | 124 } |
125 if (asn1_cb) | 125 if (asn1_cb) |
126 » » » asn1_cb(ASN1_OP_FREE_POST, pval, it); | 126 » » » asn1_cb(ASN1_OP_FREE_POST, pval, it, NULL); |
127 if (!combine) | 127 if (!combine) |
128 { | 128 { |
129 OPENSSL_free(*pval); | 129 OPENSSL_free(*pval); |
130 *pval = NULL; | 130 *pval = NULL; |
131 } | 131 } |
132 break; | 132 break; |
133 | 133 |
134 case ASN1_ITYPE_COMPAT: | 134 case ASN1_ITYPE_COMPAT: |
135 cf = it->funcs; | 135 cf = it->funcs; |
136 if (cf && cf->asn1_free) | 136 if (cf && cf->asn1_free) |
137 cf->asn1_free(*pval); | 137 cf->asn1_free(*pval); |
138 break; | 138 break; |
139 | 139 |
140 case ASN1_ITYPE_EXTERN: | 140 case ASN1_ITYPE_EXTERN: |
141 ef = it->funcs; | 141 ef = it->funcs; |
142 if (ef && ef->asn1_ex_free) | 142 if (ef && ef->asn1_ex_free) |
143 ef->asn1_ex_free(pval, it); | 143 ef->asn1_ex_free(pval, it); |
144 break; | 144 break; |
145 | 145 |
146 case ASN1_ITYPE_NDEF_SEQUENCE: | 146 case ASN1_ITYPE_NDEF_SEQUENCE: |
147 case ASN1_ITYPE_SEQUENCE: | 147 case ASN1_ITYPE_SEQUENCE: |
148 if (asn1_do_lock(pval, -1, it) > 0) | 148 if (asn1_do_lock(pval, -1, it) > 0) |
149 return; | 149 return; |
150 if (asn1_cb) | 150 if (asn1_cb) |
151 { | 151 { |
152 » » » i = asn1_cb(ASN1_OP_FREE_PRE, pval, it); | 152 » » » i = asn1_cb(ASN1_OP_FREE_PRE, pval, it, NULL); |
153 if (i == 2) | 153 if (i == 2) |
154 return; | 154 return; |
155 } | 155 } |
156 asn1_enc_free(pval, it); | 156 asn1_enc_free(pval, it); |
157 /* If we free up as normal we will invalidate any | 157 /* If we free up as normal we will invalidate any |
158 * ANY DEFINED BY field and we wont be able to | 158 * ANY DEFINED BY field and we wont be able to |
159 * determine the type of the field it defines. So | 159 * determine the type of the field it defines. So |
160 * free up in reverse order. | 160 * free up in reverse order. |
161 */ | 161 */ |
162 tt = it->templates + it->tcount - 1; | 162 tt = it->templates + it->tcount - 1; |
163 for (i = 0; i < it->tcount; tt--, i++) | 163 for (i = 0; i < it->tcount; tt--, i++) |
164 { | 164 { |
165 ASN1_VALUE **pseqval; | 165 ASN1_VALUE **pseqval; |
166 seqtt = asn1_do_adb(pval, tt, 0); | 166 seqtt = asn1_do_adb(pval, tt, 0); |
167 if (!seqtt) | 167 if (!seqtt) |
168 continue; | 168 continue; |
169 pseqval = asn1_get_field_ptr(pval, seqtt); | 169 pseqval = asn1_get_field_ptr(pval, seqtt); |
170 ASN1_template_free(pseqval, seqtt); | 170 ASN1_template_free(pseqval, seqtt); |
171 } | 171 } |
172 if (asn1_cb) | 172 if (asn1_cb) |
173 » » » asn1_cb(ASN1_OP_FREE_POST, pval, it); | 173 » » » asn1_cb(ASN1_OP_FREE_POST, pval, it, NULL); |
174 if (!combine) | 174 if (!combine) |
175 { | 175 { |
176 OPENSSL_free(*pval); | 176 OPENSSL_free(*pval); |
177 *pval = NULL; | 177 *pval = NULL; |
178 } | 178 } |
179 break; | 179 break; |
180 } | 180 } |
181 } | 181 } |
182 | 182 |
183 void ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) | 183 void ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 OPENSSL_free(*pval); | 257 OPENSSL_free(*pval); |
258 break; | 258 break; |
259 | 259 |
260 default: | 260 default: |
261 ASN1_STRING_free((ASN1_STRING *)*pval); | 261 ASN1_STRING_free((ASN1_STRING *)*pval); |
262 *pval = NULL; | 262 *pval = NULL; |
263 break; | 263 break; |
264 } | 264 } |
265 *pval = NULL; | 265 *pval = NULL; |
266 } | 266 } |
OLD | NEW |