Add MBEDTLS_ASN1_CHK_CLEANUP_ADD macro to be able to release memory on failure

Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
This commit is contained in:
Przemek Stekiel 2023-02-24 14:03:30 +01:00
parent 5a49d3cce3
commit 57207711d8
2 changed files with 30 additions and 14 deletions

View file

@ -35,6 +35,15 @@
(g) += ret; \
} while (0)
#define MBEDTLS_ASN1_CHK_CLEANUP_ADD(g, f) \
do \
{ \
if ((ret = (f)) < 0) \
goto cleanup; \
else \
(g) += ret; \
} while (0)
#ifdef __cplusplus
extern "C" {
#endif