test: Fix memory/file pointer leaks in tests

This commit is contained in:
Rick van Schijndel 2020-04-18 10:25:04 +02:00
parent 647ac54b6f
commit e571a05240
2 changed files with 7 additions and 4 deletions

View file

@ -94,6 +94,12 @@ int main(int argc, char *argv[])
filename = argv[1];
cu8_buf = malloc(sizeof(uint8_t) * 2 * max_block_size);
n_read = read_buf(filename, cu8_buf, sizeof(uint8_t) * 2 * max_block_size);
if (n_read < 1) {
free(cu8_buf);
return 1;
}
y16_buf = malloc(sizeof(uint16_t) * max_block_size);
cs16_buf = malloc(sizeof(int16_t) * 2 * max_block_size);
y32_buf = malloc(sizeof(uint32_t) * max_block_size);
@ -102,10 +108,6 @@ int main(int argc, char *argv[])
s16_buf = malloc(sizeof(int16_t) * max_block_size);
s32_buf = malloc(sizeof(int32_t) * max_block_size);
n_read = read_buf(filename, cu8_buf, sizeof(uint8_t) * 2 * max_block_size);
if (n_read < 1) {
return 1;
}
n_samples = n_read / (sizeof(uint8_t) * 2);
for (unsigned long i = 0; i < n_samples * 2; i++) {

View file

@ -87,6 +87,7 @@ static int style_check(char *path)
need_cond++;
}
}
fclose(fp);
if (leading_tabs && leading_spcs) {
tabs_errors = leading_tabs > leading_spcs ? leading_spcs : leading_tabs;
}