Added nullptr checks around file access
@@ -180,13 +180,16 @@ int survive_load_htc_config_format(char *ct0conf, int len, SurviveObject *so) {
sprintf(fname, "calinfo/%s_points.csv", so->codename);
FILE *f = fopen(fname, "w");
int j;
+ if(f) {
for (j = 0; j < so->nr_locations; j++) {
fprintf(f, "%f %f %f\n", so->sensor_locations[j * 3 + 0],
so->sensor_locations[j * 3 + 1],
so->sensor_locations[j * 3 + 2]);
}
fclose(f);
+ }
+ if(f) {
sprintf(fname, "calinfo/%s_normals.csv", so->codename);
f = fopen(fname, "w");
for (j = 0; j < so->nr_locations; j++) {
@@ -194,6 +197,7 @@ int survive_load_htc_config_format(char *ct0conf, int len, SurviveObject *so) {
so->sensor_normals[j * 3 + 1], so->sensor_normals[j * 3 + 2]);
}
fclose(f);
+ }
return 0;
}
