1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-29 11:41:15 +03:00

Fix memory leak in example programs

Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
This commit is contained in:
Max Fillinger
2024-11-13 15:19:03 +01:00
parent 92b7a7e233
commit 144cccecb7
2 changed files with 4 additions and 0 deletions

View File

@ -2518,6 +2518,7 @@ usage:
opt.exp_label, strlen(opt.exp_label), opt.exp_label, strlen(opt.exp_label),
NULL, 0, 0); NULL, 0, 0);
if (ret != 0) { if (ret != 0) {
mbedtls_free(exported_key);
goto exit; goto exit;
} }
mbedtls_printf("Exporting key of length %d with label \"%s\": 0x", mbedtls_printf("Exporting key of length %d with label \"%s\": 0x",
@ -2528,6 +2529,7 @@ usage:
} }
mbedtls_printf("\n\n"); mbedtls_printf("\n\n");
fflush(stdout); fflush(stdout);
mbedtls_free(exported_key);
} }
#endif /* defined(MBEDTLS_SSL_KEYING_MATERIAL_EXPORT) */ #endif /* defined(MBEDTLS_SSL_KEYING_MATERIAL_EXPORT) */

View File

@ -3638,6 +3638,7 @@ handshake:
opt.exp_label, strlen(opt.exp_label), opt.exp_label, strlen(opt.exp_label),
NULL, 0, 0); NULL, 0, 0);
if (ret != 0) { if (ret != 0) {
mbedtls_free(exported_key);
goto exit; goto exit;
} }
mbedtls_printf("Exporting key of length %d with label \"%s\": 0x", mbedtls_printf("Exporting key of length %d with label \"%s\": 0x",
@ -3648,6 +3649,7 @@ handshake:
} }
mbedtls_printf("\n\n"); mbedtls_printf("\n\n");
fflush(stdout); fflush(stdout);
mbedtls_free(exported_key);
} }
#endif /* defined(MBEDTLS_SSL_KEYING_MATERIAL_EXPORT) */ #endif /* defined(MBEDTLS_SSL_KEYING_MATERIAL_EXPORT) */