Skip to content

Commit 2859b51

Browse files
authored
Add PROTECT to dims (#321)
1 parent a9f96f3 commit 2859b51

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/wrappersc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,11 @@ extern SEXP biomee_f_C(
224224

225225
// Dimensions
226226
int pDims[4] = {50, nt_annual_trans, 35, n_lu};
227-
SEXP dims = allocVector(INTSXP, 4);
227+
SEXP dims = PROTECT( allocVector(INTSXP, 4) );
228228
// INTEGER(dims) is a int* which we initialise with pDims
229229
memcpy(INTEGER(dims), pDims, 4 * sizeof(int));
230230
// Allocate 4D array
231-
SEXP output_annual_cohort_tile = PROTECT(allocArray(REALSXP, dims));
231+
SEXP output_annual_cohort_tile = PROTECT( allocArray(REALSXP, dims) );
232232

233233
SEXP output_annual_aggregated = PROTECT( allocMatrix(REALSXP, nt_annual, 71) );
234234
/****************/
@@ -263,7 +263,7 @@ extern SEXP biomee_f_C(
263263
SET_VECTOR_ELT(out_list, 2, output_annual_cohort_tile);
264264
SET_VECTOR_ELT(out_list, 3, output_annual_aggregated);
265265

266-
UNPROTECT(5);
266+
UNPROTECT(6);
267267

268268
return out_list;
269269
}

0 commit comments

Comments
 (0)