diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/asn1/bio_ndef.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/lib/libcrypto/asn1/bio_ndef.c b/src/lib/libcrypto/asn1/bio_ndef.c index 88b204e8aa..6266d68bbd 100644 --- a/src/lib/libcrypto/asn1/bio_ndef.c +++ b/src/lib/libcrypto/asn1/bio_ndef.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bio_ndef.c,v 1.11 2021/12/25 13:17:48 jsing Exp $ */ | 1 | /* $OpenBSD: bio_ndef.c,v 1.12 2023/03/06 19:10:14 tb Exp $ */ |
| 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. | 3 | * project. |
| 4 | */ | 4 | */ |
| @@ -178,29 +178,34 @@ ndef_prefix(BIO *b, unsigned char **pbuf, int *plen, void *parg) | |||
| 178 | static int | 178 | static int |
| 179 | ndef_prefix_free(BIO *b, unsigned char **pbuf, int *plen, void *parg) | 179 | ndef_prefix_free(BIO *b, unsigned char **pbuf, int *plen, void *parg) |
| 180 | { | 180 | { |
| 181 | NDEF_SUPPORT *ndef_aux; | 181 | NDEF_SUPPORT **pndef_aux = parg; |
| 182 | 182 | ||
| 183 | if (!parg) | 183 | if (pndef_aux == NULL || *pndef_aux == NULL) |
| 184 | return 0; | 184 | return 0; |
| 185 | 185 | ||
| 186 | ndef_aux = *(NDEF_SUPPORT **)parg; | 186 | free((*pndef_aux)->derbuf); |
| 187 | (*pndef_aux)->derbuf = NULL; | ||
| 187 | 188 | ||
| 188 | free(ndef_aux->derbuf); | ||
| 189 | |||
| 190 | ndef_aux->derbuf = NULL; | ||
| 191 | *pbuf = NULL; | 189 | *pbuf = NULL; |
| 192 | *plen = 0; | 190 | *plen = 0; |
| 191 | |||
| 193 | return 1; | 192 | return 1; |
| 194 | } | 193 | } |
| 195 | 194 | ||
| 196 | static int | 195 | static int |
| 197 | ndef_suffix_free(BIO *b, unsigned char **pbuf, int *plen, void *parg) | 196 | ndef_suffix_free(BIO *b, unsigned char **pbuf, int *plen, void *parg) |
| 198 | { | 197 | { |
| 199 | NDEF_SUPPORT **pndef_aux = (NDEF_SUPPORT **)parg; | 198 | NDEF_SUPPORT **pndef_aux = parg; |
| 199 | |||
| 200 | /* Ensure ndef_prefix_free() won't fail, so we won't leak *pndef_aux. */ | ||
| 201 | if (pndef_aux == NULL || *pndef_aux == NULL) | ||
| 202 | return 0; | ||
| 200 | if (!ndef_prefix_free(b, pbuf, plen, parg)) | 203 | if (!ndef_prefix_free(b, pbuf, plen, parg)) |
| 201 | return 0; | 204 | return 0; |
| 205 | |||
| 202 | free(*pndef_aux); | 206 | free(*pndef_aux); |
| 203 | *pndef_aux = NULL; | 207 | *pndef_aux = NULL; |
| 208 | |||
| 204 | return 1; | 209 | return 1; |
| 205 | } | 210 | } |
| 206 | 211 | ||
