Skip to content

Commit 0a4b054

Browse files
committed
Minor changes to ALTREP object protection.
1 parent f3be196 commit 0a4b054

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/s2-constructors-formatters.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,18 @@ SEXP builder_vector_end(const wk_vector_meta_t* meta, void* handler_data) {
112112
builder_result_finalize(data);
113113

114114
// make the result into a s2_geography object
115-
SEXP result = data->result;
116-
if (data->use_altrep) result = PROTECT(make_s2_geography_altrep(result));
115+
SEXP result;
116+
if (data->use_altrep) {
117+
result = PROTECT(make_s2_geography_altrep(data->result));
118+
} else {
119+
result = PROTECT(data->result);
120+
}
117121

118122
SEXP cls = PROTECT(Rf_allocVector(STRSXP, 2));
119123
SET_STRING_ELT(cls, 0, Rf_mkChar("s2_geography"));
120124
SET_STRING_ELT(cls, 1, Rf_mkChar("wk_vctr"));
121125
Rf_setAttrib(result, R_ClassSymbol, cls);
122-
UNPROTECT(1);
123-
124-
if (data->use_altrep) UNPROTECT(1);
126+
UNPROTECT(2);
125127

126128
return result;
127129
}

0 commit comments

Comments
 (0)