Skip to content

Commit

Permalink
Protect names
Browse files Browse the repository at this point in the history
  • Loading branch information
lionel- committed Mar 15, 2019
1 parent c16d90c commit 3ade1b2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/utils.cpp
Expand Up @@ -80,13 +80,19 @@ SEXP get_element_names(const List& x, int i) {
}

void check_dataframes_names_consistency(const List& x) {
SEXP ref = get_element_names(x, 0);
int n_protect = 0;

SEXP ref = PROTECT(get_element_names(x, 0));
++n_protect;

if (TYPEOF(ref) != STRSXP) {
goto error;
}

for (int i = 0; i < x.size(); ++i) {
SEXP names = get_element_names(x, i);
SEXP names = PROTECT(get_element_names(x, i));
++n_protect;

if (TYPEOF(names) != STRSXP) {
goto error;
}
Expand All @@ -100,6 +106,7 @@ void check_dataframes_names_consistency(const List& x) {
}
}

UNPROTECT(n_protect);
return;

error:
Expand Down

0 comments on commit 3ade1b2

Please sign in to comment.