From a3e260436a2a763bad200bfe49dfd1ade04caa4d Mon Sep 17 00:00:00 2001 From: Pablo de Lara Date: Fri, 15 Dec 2023 09:16:43 +0000 Subject: [PATCH] erasure_code: [test] fix memory leak Signed-off-by: Pablo de Lara --- erasure_code/erasure_code_test.c | 95 +++++++++++++------- erasure_code/erasure_code_update_test.c | 111 ++++++++++++++++-------- erasure_code/gf_inverse_test.c | 29 ++++--- erasure_code/gf_vect_mul_test.c | 40 +++++---- 4 files changed, 181 insertions(+), 94 deletions(-) diff --git a/erasure_code/erasure_code_test.c b/erasure_code/erasure_code_test.c index 63ae37b..1e66332 100644 --- a/erasure_code/erasure_code_test.c +++ b/erasure_code/erasure_code_test.c @@ -215,13 +215,14 @@ static int gf_gen_decode_matrix(unsigned char *encode_matrix, int main(int argc, char *argv[]) { - int re = 0; + int re = -1; int i, j, p, rtest, m, k; int nerrs, nsrcerrs; void *buf; unsigned int decode_index[MMAX]; - unsigned char *temp_buffs[TEST_SOURCES], *buffs[TEST_SOURCES]; - unsigned char *encode_matrix, *decode_matrix, *invert_matrix, *g_tbls; + unsigned char *temp_buffs[TEST_SOURCES] = { NULL }, *buffs[TEST_SOURCES] = { NULL }; + unsigned char *encode_matrix = NULL, *decode_matrix = NULL, *invert_matrix = + NULL, *g_tbls = NULL; unsigned char src_in_err[TEST_SOURCES], src_err_list[TEST_SOURCES]; unsigned char *recov[TEST_SOURCES]; @@ -238,7 +239,7 @@ int main(int argc, char *argv[]) for (i = 0; i < TEST_SOURCES; i++) { if (posix_memalign(&buf, 64, TEST_LEN)) { printf("alloc error: Fail"); - return -1; + goto exit; } buffs[i] = buf; } @@ -246,7 +247,7 @@ int main(int argc, char *argv[]) for (i = 0; i < TEST_SOURCES; i++) { if (posix_memalign(&buf, 64, TEST_LEN)) { printf("alloc error: Fail"); - return -1; + goto exit; } temp_buffs[i] = buf; } @@ -260,13 +261,15 @@ int main(int argc, char *argv[]) if (encode_matrix == NULL || decode_matrix == NULL || invert_matrix == NULL || g_tbls == NULL) { printf("Test failure! Error with malloc\n"); - return -1; + goto exit; } // Pick a first test m = 9; k = 5; - if (m > MMAX || k > KMAX) - return -1; + if (m > MMAX || k > KMAX) { + re = -1; + goto exit; + } // Make random data for (i = 0; i < k; i++) @@ -295,7 +298,7 @@ int main(int argc, char *argv[]) nerrs, nsrcerrs, k, m); if (re != 0) { printf("Fail to gf_gen_decode_matrix\n"); - return -1; + goto exit; } // Pack recovery array as list of valid sources // Its order must be the same as the order @@ -327,15 +330,18 @@ int main(int argc, char *argv[]) dump(temp_buffs[k + i], 25); printf("orig :"); dump(buffs[src_err_list[i]], 25); - return -1; + re = -1; + goto exit; } } // Pick a first test m = 9; k = 5; - if (m > MMAX || k > KMAX) - return -1; + if (m > MMAX || k > KMAX) { + re = -1; + goto exit; + } // Make random data for (i = 0; i < k; i++) @@ -363,7 +369,7 @@ int main(int argc, char *argv[]) nerrs, nsrcerrs, k, m); if (re != 0) { printf("Fail to gf_gen_decode_matrix\n"); - return -1; + goto exit; } // Pack recovery array as list of valid sources // Its order must be the same as the order @@ -395,7 +401,8 @@ int main(int argc, char *argv[]) dump(temp_buffs[k + i], 25); printf("orig :"); dump(buffs[src_err_list[i]], 25); - return -1; + re = -1; + goto exit; } } @@ -433,7 +440,7 @@ int main(int argc, char *argv[]) src_in_err, nerrs, nsrcerrs, k, m); if (re != 0) { printf("Fail to gf_gen_decode_matrix\n"); - return -1; + goto exit; } // Pack recovery array as list of valid sources // Its order must be the same as the order @@ -468,7 +475,8 @@ int main(int argc, char *argv[]) dump(buffs[src_err_list[i]], 25); printf("recov %d:", src_err_list[i]); dump(temp_buffs[k + i], 25); - return -1; + re = -1; + goto exit; } } #ifdef TEST_VERBOSE @@ -479,13 +487,17 @@ int main(int argc, char *argv[]) // Run tests at end of buffer for Electric Fence k = 16; align = (LEN_ALIGN_CHK_B != 0) ? 1 : 16; - if (k > KMAX) - return -1; + if (k > KMAX) { + re = -1; + goto exit; + } for (rows = 1; rows <= 16; rows++) { m = k + rows; - if (m > MMAX) - return -1; + if (m > MMAX) { + re = -1; + goto exit; + } // Make random data for (i = 0; i < k; i++) @@ -518,7 +530,7 @@ int main(int argc, char *argv[]) src_in_err, nerrs, nsrcerrs, k, m); if (re != 0) { printf("Fail to gf_gen_decode_matrix\n"); - return -1; + goto exit; } // Pack recovery array as list of valid sources // Its order must be the same as the order @@ -558,7 +570,8 @@ int main(int argc, char *argv[]) dump(temp_buffs[k + i], align); printf("orig :"); dump(efence_buffs[src_err_list[i]], align); - return -1; + re = -1; + goto exit; } } } @@ -610,7 +623,7 @@ int main(int argc, char *argv[]) src_in_err, nerrs, nsrcerrs, k, m); if (re != 0) { printf("Fail to gf_gen_decode_matrix\n"); - return -1; + goto exit; } // Pack recovery array as list of valid sources // Its order must be the same as the order @@ -645,7 +658,8 @@ int main(int argc, char *argv[]) dump(ubuffs[src_err_list[i]], 25); printf("recov %d:", src_err_list[i]); dump(temp_ubuffs[k + i], 25); - return -1; + re = -1; + goto exit; } } @@ -658,13 +672,15 @@ int main(int argc, char *argv[]) if (memcmp(buffs[i], temp_buffs[0], offset)) { printf("Fail rand ualign encode pad start\n"); - return -1; + re = -1; + goto exit; } if (memcmp (buffs[i] + offset + size, temp_buffs[0], PTR_ALIGN_CHK_B - offset)) { printf("Fail rand ualign encode pad end\n"); - return -1; + re = -1; + goto exit; } } @@ -673,13 +689,15 @@ int main(int argc, char *argv[]) offset = temp_ubuffs[k + i] - temp_buffs[k + i]; if (memcmp(temp_buffs[k + i], temp_buffs[0], offset)) { printf("Fail rand ualign decode pad start\n"); - return -1; + re = -1; + goto exit; } if (memcmp (temp_buffs[k + i] + offset + size, temp_buffs[0], PTR_ALIGN_CHK_B - offset)) { printf("Fail rand ualign decode pad end\n"); - return -1; + re = -1; + goto exit; } } @@ -723,7 +741,7 @@ int main(int argc, char *argv[]) src_in_err, nerrs, nsrcerrs, k, m); if (re != 0) { printf("Fail to gf_gen_decode_matrix\n"); - return -1; + goto exit; } // Pack recovery array as list of valid sources // Its order must be the same as the order @@ -758,11 +776,26 @@ int main(int argc, char *argv[]) dump(buffs[src_err_list[i]], 25); printf("recov %d:", src_err_list[i]); dump(temp_buffs[k + i], 25); - return -1; + re = -1; + goto exit; } } } printf("done EC tests: Pass\n"); - return 0; + re = 0; + + exit: + for (i = 0; i < TEST_SOURCES; i++) { + if (buffs[i]) + aligned_free(buffs[i]); + if (temp_buffs[i]) + aligned_free(temp_buffs[i]); + } + free(encode_matrix); + free(decode_matrix); + free(invert_matrix); + free(g_tbls); + + return re; } diff --git a/erasure_code/erasure_code_update_test.c b/erasure_code/erasure_code_update_test.c index b2ab9e7..4e1fe89 100644 --- a/erasure_code/erasure_code_update_test.c +++ b/erasure_code/erasure_code_update_test.c @@ -227,14 +227,15 @@ static int gf_gen_decode_matrix(unsigned char *encode_matrix, int main(int argc, char *argv[]) { - int re = 0; + int re = -1; int i, j, p, rtest, m, k; int nerrs, nsrcerrs; void *buf; unsigned int decode_index[MMAX]; - unsigned char *temp_buffs[TEST_SOURCES], *buffs[TEST_SOURCES]; - unsigned char *update_buffs[TEST_SOURCES]; - unsigned char *encode_matrix, *decode_matrix, *invert_matrix, *g_tbls; + unsigned char *temp_buffs[TEST_SOURCES] = { NULL }, *buffs[TEST_SOURCES] = { NULL }; + unsigned char *update_buffs[TEST_SOURCES] = { NULL }; + unsigned char *encode_matrix = NULL, *decode_matrix = NULL, *invert_matrix = + NULL, *g_tbls = NULL; unsigned char src_in_err[TEST_SOURCES], src_err_list[TEST_SOURCES]; unsigned char *recov[TEST_SOURCES]; @@ -253,7 +254,7 @@ int main(int argc, char *argv[]) for (i = 0; i < TEST_SOURCES; i++) { if (posix_memalign(&buf, 64, TEST_LEN)) { printf("alloc error: Fail"); - return -1; + goto exit; } buffs[i] = buf; } @@ -261,7 +262,7 @@ int main(int argc, char *argv[]) for (i = 0; i < TEST_SOURCES; i++) { if (posix_memalign(&buf, 64, TEST_LEN)) { printf("alloc error: Fail"); - return -1; + goto exit; } temp_buffs[i] = buf; memset(temp_buffs[i], 0, TEST_LEN); // initialize the destination buffer to be zero for update function @@ -270,7 +271,7 @@ int main(int argc, char *argv[]) for (i = 0; i < TEST_SOURCES; i++) { if (posix_memalign(&buf, 64, TEST_LEN)) { printf("alloc error: Fail"); - return -1; + goto exit; } update_buffs[i] = buf; memset(update_buffs[i], 0, TEST_LEN); // initialize the destination buffer to be zero for update function @@ -284,13 +285,13 @@ int main(int argc, char *argv[]) if (encode_matrix == NULL || decode_matrix == NULL || invert_matrix == NULL || g_tbls == NULL) { printf("Test failure! Error with malloc\n"); - return -1; + goto exit; } // Pick a first test m = 14; k = 10; if (m > MMAX || k > KMAX) - return -1; + goto exit; // Make random data for (i = 0; i < k; i++) { @@ -321,7 +322,7 @@ int main(int argc, char *argv[]) dump(update_buffs[k + i], 25); printf("buffs%d :", i); dump(buffs[k + i], 25); - return -1; + goto exit; } } @@ -335,7 +336,7 @@ int main(int argc, char *argv[]) nerrs, nsrcerrs, k, m); if (re != 0) { printf("Fail to gf_gen_decode_matrix\n"); - return -1; + goto exit; } // Pack recovery array as list of valid sources // Its order must be the same as the order @@ -367,7 +368,8 @@ int main(int argc, char *argv[]) dump(temp_buffs[k + i], 25); printf("orig :"); dump(update_buffs[src_err_list[i]], 25); - return -1; + re = -1; + goto exit; } } #ifdef TEST_VERBOSE @@ -377,8 +379,10 @@ int main(int argc, char *argv[]) // Pick a first test m = 7; k = 5; - if (m > MMAX || k > KMAX) - return -1; + if (m > MMAX || k > KMAX) { + re = -1; + goto exit; + } // Zero the destination buffer for update function for (i = k; i < TEST_SOURCES; i++) { @@ -413,7 +417,8 @@ int main(int argc, char *argv[]) dump(update_buffs[k + i], 25); printf("buffs%d :", i); dump(buffs[k + i], 25); - return -1; + re = -1; + goto exit; } } @@ -427,7 +432,7 @@ int main(int argc, char *argv[]) nerrs, nsrcerrs, k, m); if (re != 0) { printf("Fail to gf_gen_decode_matrix\n"); - return -1; + goto exit; } // Pack recovery array as list of valid sources // Its order must be the same as the order @@ -464,7 +469,8 @@ int main(int argc, char *argv[]) dump(temp_buffs[k + i], 25); printf("orig :"); dump(update_buffs[src_err_list[i]], 25); - return -1; + re = -1; + goto exit; } } #ifdef TEST_VERBOSE @@ -512,7 +518,8 @@ int main(int argc, char *argv[]) dump(update_buffs[k + i], 25); printf("buffs%d :", i); dump(buffs[k + i], 25); - return -1; + re = -1; + goto exit; } } @@ -526,7 +533,7 @@ int main(int argc, char *argv[]) src_in_err, nerrs, nsrcerrs, k, m); if (re != 0) { printf("Fail to gf_gen_decode_matrix\n"); - return -1; + goto exit; } // Pack recovery array as list of valid sources // Its order must be the same as the order @@ -569,7 +576,8 @@ int main(int argc, char *argv[]) dump(update_buffs[src_err_list[i]], 25); printf("recov %d:", src_err_list[i]); dump(temp_buffs[k + i], 25); - return -1; + re = -1; + goto exit; } } #ifdef TEST_VERBOSE @@ -580,13 +588,17 @@ int main(int argc, char *argv[]) // Run tests at end of buffer for Electric Fence k = 16; align = (LEN_ALIGN_CHK_B != 0) ? 1 : ALIGN_SIZE; - if (k > KMAX) - return -1; + if (k > KMAX) { + re = -1; + goto exit; + } for (rows = 1; rows <= 16; rows++) { m = k + rows; - if (m > MMAX) - return -1; + if (m > MMAX) { + re = -1; + goto exit; + } for (i = k; i < TEST_SOURCES; i++) { memset(buffs[i], 0, TEST_LEN); @@ -634,7 +646,8 @@ int main(int argc, char *argv[]) dump(efence_update_buffs[k + i], 25); printf("efence_buffs%d :", i); dump(efence_buffs[k + i], 25); - return -1; + re = -1; + goto exit; } } @@ -648,7 +661,7 @@ int main(int argc, char *argv[]) src_in_err, nerrs, nsrcerrs, k, m); if (re != 0) { printf("Fail to gf_gen_decode_matrix\n"); - return -1; + goto exit; } // Pack recovery array as list of valid sources // Its order must be the same as the order @@ -694,7 +707,8 @@ int main(int argc, char *argv[]) dump(temp_buffs[k + i], align); printf("orig :"); dump(efence_update_buffs[src_err_list[i]], align); - return -1; + re = 1; + goto exit; } } } @@ -760,7 +774,8 @@ int main(int argc, char *argv[]) dump(update_ubuffs[k + i], 25); printf("ubuffs%d :", i); dump(ubuffs[k + i], 25); - return -1; + re = -1; + goto exit; } } @@ -774,7 +789,7 @@ int main(int argc, char *argv[]) src_in_err, nerrs, nsrcerrs, k, m); if (re != 0) { printf("Fail to gf_gen_decode_matrix\n"); - return -1; + goto exit; } // Pack recovery array as list of valid sources // Its order must be the same as the order @@ -816,7 +831,8 @@ int main(int argc, char *argv[]) dump(update_ubuffs[src_err_list[i]], 25); printf("recov %d:", src_err_list[i]); dump(temp_ubuffs[k + i], 25); - return -1; + re = -1; + goto exit; } } @@ -829,13 +845,15 @@ int main(int argc, char *argv[]) if (memcmp(update_buffs[i], temp_buffs[0], offset)) { printf("Fail rand ualign encode pad start\n"); - return -1; + re = -1; + goto exit; } if (memcmp (update_buffs[i] + offset + size, temp_buffs[0], PTR_ALIGN_CHK_B - offset)) { printf("Fail rand ualign encode pad end\n"); - return -1; + re = -1; + goto exit; } } @@ -844,13 +862,15 @@ int main(int argc, char *argv[]) offset = temp_ubuffs[k + i] - temp_buffs[k + i]; if (memcmp(temp_buffs[k + i], temp_buffs[0], offset)) { printf("Fail rand ualign decode pad start\n"); - return -1; + re = -1; + goto exit; } if (memcmp (temp_buffs[k + i] + offset + size, temp_buffs[0], PTR_ALIGN_CHK_B - offset)) { printf("Fail rand ualign decode pad end\n"); - return -1; + re = -1; + goto exit; } } @@ -903,7 +923,8 @@ int main(int argc, char *argv[]) dump(update_buffs[k + i], 25); printf("buffs%d (size=%d) :", i, size); dump(buffs[k + i], 25); - return -1; + re = -1; + goto exit; } } @@ -916,7 +937,7 @@ int main(int argc, char *argv[]) src_in_err, nerrs, nsrcerrs, k, m); if (re != 0) { printf("Fail to gf_gen_decode_matrix\n"); - return -1; + goto exit; } // Pack recovery array as list of valid sources // Its order must be the same as the order @@ -958,7 +979,8 @@ int main(int argc, char *argv[]) dump(update_buffs[src_err_list[i]], 25); printf("recov %d:", src_err_list[i]); dump(temp_buffs[k + i], 25); - return -1; + re = -1; + goto exit; } } #ifdef TEST_VERBOSE @@ -967,5 +989,20 @@ int main(int argc, char *argv[]) } printf("done EC tests: Pass\n"); + re = 0; + + exit: + for (i = 0; i < TEST_SOURCES; i++) { + if (buffs[i]) + aligned_free(buffs[i]); + if (temp_buffs[i]) + aligned_free(temp_buffs[i]); + if (update_buffs[i]) + aligned_free(update_buffs[i]); + } + free(encode_matrix); + free(decode_matrix); + free(invert_matrix); + free(g_tbls); return 0; } diff --git a/erasure_code/gf_inverse_test.c b/erasure_code/gf_inverse_test.c index 51f52e0..1aa14ad 100644 --- a/erasure_code/gf_inverse_test.c +++ b/erasure_code/gf_inverse_test.c @@ -121,7 +121,8 @@ int inv_test(u8 * in, u8 * inv, u8 * sav, int n) int main(int argc, char *argv[]) { int i, k, t; - u8 *test_mat, *save_mat, *invr_mat; + u8 *test_mat = NULL, *save_mat = NULL, *invr_mat = NULL; + int ret = -1; u8 test1[] = { 1, 1, 6, 1, 1, 1, @@ -151,25 +152,25 @@ int main(int argc, char *argv[]) invr_mat = malloc(KMAX * KMAX); if (NULL == test_mat || NULL == save_mat || NULL == invr_mat) - return -1; + goto exit; // Test with lots of leading 1's k = 3; memcpy(test_mat, test1, k * k); if (inv_test(test_mat, invr_mat, save_mat, k)) - return -1; + goto exit; // Test with leading zeros k = 3; memcpy(test_mat, test2, k * k); if (inv_test(test_mat, invr_mat, save_mat, k)) - return -1; + goto exit; // Test 3 k = 3; memcpy(test_mat, test3, k * k); if (inv_test(test_mat, invr_mat, save_mat, k)) - return -1; + goto exit; // Test 4 - try a singular matrix k = 4; @@ -177,7 +178,7 @@ int main(int argc, char *argv[]) if (!gf_invert_matrix(test_mat, invr_mat, k)) { printf("Fail: didn't catch singular matrix\n"); print_matrix(test4, 4); - return -1; + goto exit; } // Do random test of size KMAX k = KMAX; @@ -187,7 +188,7 @@ int main(int argc, char *argv[]) if (gf_invert_matrix(test_mat, invr_mat, k)) { printf("rand picked a singular matrix, try again\n"); - return -1; + goto exit; } matrix_mult(invr_mat, save_mat, test_mat, k); @@ -197,7 +198,7 @@ int main(int argc, char *argv[]) print_matrix(save_mat, k); print_matrix(invr_mat, k); print_matrix(test_mat, k); - return -1; + goto exit; } // Do Randoms. Random size and coefficients for (t = 0; t < RANDOMS; t++) { @@ -216,7 +217,7 @@ int main(int argc, char *argv[]) print_matrix(save_mat, k); print_matrix(invr_mat, k); print_matrix(test_mat, k); - return -1; + goto exit; } #ifdef TEST_VERBOSE if (0 == (t % 8)) @@ -225,5 +226,13 @@ int main(int argc, char *argv[]) } printf(" Pass\n"); - return 0; + + ret = 0; + + exit: + free(test_mat); + free(save_mat); + free(invr_mat); + + return ret; } diff --git a/erasure_code/gf_vect_mul_test.c b/erasure_code/gf_vect_mul_test.c index cc7e1bd..617365c 100644 --- a/erasure_code/gf_vect_mul_test.c +++ b/erasure_code/gf_vect_mul_test.c @@ -37,8 +37,8 @@ typedef unsigned char u8; int main(int argc, char *argv[]) { - int i; - u8 *buff1, *buff2, *buff3, gf_const_tbl[64], a = 2; + int i, ret = -1; + u8 *buff1 = NULL, *buff2 = NULL, *buff3 = NULL, gf_const_tbl[64], a = 2; int tsize; int align, size; unsigned char *efence_buff1; @@ -55,7 +55,7 @@ int main(int argc, char *argv[]) if (NULL == buff1 || NULL == buff2 || NULL == buff3) { printf("buffer alloc error\n"); - return -1; + goto exit; } // Fill with rand data for (i = 0; i < TEST_SIZE; i++) @@ -63,27 +63,27 @@ int main(int argc, char *argv[]) if (gf_vect_mul(TEST_SIZE, gf_const_tbl, buff1, buff2) != 0) { printf("fail creating buff2\n"); - return -1; + goto exit; } for (i = 0; i < TEST_SIZE; i++) { if (gf_mul(a, buff1[i]) != buff2[i]) { printf("fail at %d, 0x%x x 2 = 0x%x (0x%x)\n", i, buff1[i], buff2[i], gf_mul(2, buff1[i])); - return -1; + goto exit; } } if (gf_vect_mul_base(TEST_SIZE, gf_const_tbl, buff1, buff3) != 0) { printf("fail fill with rand data\n"); - return -1; + goto exit; } // Check reference function for (i = 0; i < TEST_SIZE; i++) { if (buff2[i] != buff3[i]) { printf("fail at %d, 0x%x x 0x%d = 0x%x (0x%x)\n", i, a, buff1[i], buff2[i], gf_mul(a, buff1[i])); - return -1; + goto exit; } } @@ -95,14 +95,14 @@ int main(int argc, char *argv[]) gf_vect_mul_init(a, gf_const_tbl); if (gf_vect_mul(TEST_SIZE, gf_const_tbl, buff1, buff2) != 0) { printf("fail creating buff2\n"); - return -1; + goto exit; } for (i = 0; i < TEST_SIZE; i++) if (gf_mul(a, buff1[i]) != buff2[i]) { printf("fail at %d, 0x%x x %d = 0x%x (0x%x)\n", i, a, buff1[i], buff2[i], gf_mul(2, buff1[i])); - return -1; + goto exit; } #ifdef TEST_VERBOSE putchar('.'); @@ -115,14 +115,14 @@ int main(int argc, char *argv[]) gf_vect_mul_init(a, gf_const_tbl); if (gf_vect_mul(tsize, gf_const_tbl, buff1, buff2) != 0) { printf("fail creating buff2 (len %d)\n", tsize); - return -1; + goto exit; } for (i = 0; i < tsize; i++) if (gf_mul(a, buff1[i]) != buff2[i]) { printf("fail at %d, 0x%x x %d = 0x%x (0x%x)\n", i, a, buff1[i], buff2[i], gf_mul(2, buff1[i])); - return -1; + goto exit; } #ifdef TEST_VERBOSE if (0 == tsize % (32 * 8)) { @@ -150,13 +150,13 @@ int main(int argc, char *argv[]) printf("fail at %d, 0x%x x 2 = 0x%x (0x%x)\n", i, efence_buff1[i], efence_buff2[i], gf_mul(2, efence_buff1[i])); - return 1; + goto exit; } if (gf_vect_mul_base (TEST_SIZE - size, gf_const_tbl, efence_buff1, efence_buff3) != 0) { printf("fail line up TEST_SIZE from end\n"); - return -1; + goto exit; } // Check reference function for (i = 0; i < TEST_SIZE - size; i++) @@ -164,7 +164,7 @@ int main(int argc, char *argv[]) printf("fail at %d, 0x%x x 0x%d = 0x%x (0x%x)\n", i, a, efence_buff2[i], efence_buff3[i], gf_mul(2, efence_buff1[i])); - return 1; + goto exit; } #ifdef TEST_VERBOSE putchar('.'); @@ -177,11 +177,19 @@ int main(int argc, char *argv[]) printf ("fail expecting nonzero return code for unaligned size param (%d)\n", size); - return 1; + goto exit; } } printf(" done: Pass\n"); fflush(0); - return 0; + + ret = 0; + exit: + + free(buff1); + free(buff2); + free(buff3); + + return ret; }