check malloc return value in various tests

master
Andre Puschmann 7 years ago
parent f17cfa3ac3
commit 8f850754f3

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

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

Loading…
Cancel
Save