Skip to content

Commit

Permalink
Merge pull request #8620 from davidhorstmann-arm/fix-selftest-doublef…
Browse files Browse the repository at this point in the history
…ree-2.28

[Backport 2.28] Fix potential double-free in calloc selftest
  • Loading branch information
paul-elliott-arm authored Dec 8, 2023
2 parents f09b837 + 05fde60 commit 0dc3ed0
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions programs/test/selftest.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ static int calloc_self_test(int verbose)
if (verbose) {
mbedtls_printf(" CALLOC(0,1): passed (same non-null)\n");
}
empty2 = NULL;
} else {
if (verbose) {
mbedtls_printf(" CALLOC(0,1): passed (distinct non-null)\n");
Expand All @@ -107,6 +108,7 @@ static int calloc_self_test(int verbose)
if (verbose) {
mbedtls_printf(" CALLOC(1,0): passed (same non-null)\n");
}
empty2 = NULL;
} else {
if (verbose) {
mbedtls_printf(" CALLOC(1,0): passed (distinct non-null)\n");
Expand All @@ -123,6 +125,7 @@ static int calloc_self_test(int verbose)
mbedtls_printf(" CALLOC(1): failed (same buffer twice)\n");
}
++failures;
buffer2 = NULL;
} else {
if (verbose) {
mbedtls_printf(" CALLOC(1): passed\n");
Expand Down

0 comments on commit 0dc3ed0

Please sign in to comment.