check malloc return value in various tests

This commit is contained in:
Andre Puschmann 2018-02-06 16:42:43 +01:00
parent f17cfa3ac3
commit 8f850754f3
2 changed files with 15 additions and 4 deletions

View File

@ -175,6 +175,10 @@ int main(int argc, char **argv) {
}
uint8_t *data[] = {malloc(100000)};
if (!data[0]) {
perror("malloc");
exit(-1);
}
ret = -1;
nof_frames = 0;
@ -195,7 +199,8 @@ int main(int argc, char **argv) {
} while (nof_frames <= max_frames && ret == 0);
base_free();
free(data[0]);
if (data[0])
free(data[0]);
if (ret > 0) {
exit(0);
} else {

View File

@ -181,13 +181,17 @@ int main(int argc, char **argv) {
exit(-1);
}
uint8_t *data[] = {malloc(100000)};
uint8_t *data = malloc(100000);
if (!data) {
perror("malloc");
exit(-1);
}
ret = -1;
srslte_filesource_read(&fsrc, input_buffer[0], flen);
INFO("Reading %d samples sub-frame %d\n", flen, sf_idx);
ret = srslte_ue_dl_decode_mbsfn(&ue_dl, data[0], sf_idx);
ret = srslte_ue_dl_decode_mbsfn(&ue_dl, data, sf_idx);
if(ret > 0) {
printf("PMCH Decoded OK!\n");
} else if (ret < 0) {
@ -195,7 +199,9 @@ int main(int argc, char **argv) {
}
base_free();
free(data[0]);
if (data != NULL) {
free(data);
}
if (ret > 0) {
exit(0);
} else {