Skip to content

Commit

Permalink
[FIX] Repair segfault after failed open in separation sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
cfhammill committed Jun 10, 2021
1 parent 3a793ee commit abb95a1
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/minc_reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,13 @@ SEXP get_minc_separations(SEXP filename) {
mihandle_t hvol;
const char *filepath = CHAR(asChar(filename));
midimhandle_t dimensions[3];
double* voxel_separations = malloc(3 * sizeof(double));
double* voxel_separations = (double *)R_alloc(3, sizeof(double));
SEXP output = PROTECT(allocVector(REALSXP, 3));

result = miopen_volume(filepath,
MI2_OPEN_READ, &hvol);

if (result != MI_NOERROR) {
miclose_volume(hvol);
error("Error opening input file: %s.\n", filepath);
}

Expand Down Expand Up @@ -316,7 +315,7 @@ void get_hyperslab(char **filename, int *start, int *count, double *slab) {
MI_TYPE_DOUBLE,
(misize_t *) tmp_start,
(misize_t *) tmp_count,
slab)
slab)
< 0) {
error("Could not get hyperslab.\n");
}
Expand Down

0 comments on commit abb95a1

Please sign in to comment.