@@ -543,7 +543,7 @@ SEXP perhapsDataTableR(SEXP x) {
543543}
544544
545545SEXP frev (SEXP x , SEXP copyArg ) {
546- SEXP names , klass , levels ;
546+ SEXP names ;
547547 if (INHERITS (x , char_dataframe ))
548548 error (_ ("'x' should not be data.frame or data.table." ));
549549 if (!IS_TRUE_OR_FALSE (copyArg ))
@@ -631,14 +631,13 @@ SEXP frev(SEXP x, SEXP copyArg) {
631631 error (_ ("Type '%s' is not supported by frev" ), type2char (TYPEOF (x )));
632632 }
633633 names = PROTECT (getAttrib (x , R_NamesSymbol ));
634- klass = PROTECT (getAttrib (x , R_ClassSymbol ));
635- levels = PROTECT (getAttrib (x , R_LevelsSymbol ));
636- nprotect += 3 ;
634+ nprotect ++ ;
637635 if (copy ) {
638636 SET_ATTRIB (x , R_NilValue );
639637 setAttrib (x , R_NamesSymbol , names );
640- setAttrib (x , R_ClassSymbol , klass );
641- setAttrib (x , R_LevelsSymbol , levels );
638+ setAttrib (x , R_ClassSymbol , PROTECT (getAttrib (x , R_ClassSymbol )));
639+ setAttrib (x , R_LevelsSymbol , PROTECT (getAttrib (x , R_LevelsSymbol )));
640+ nprotect += 2 ;
642641 }
643642 if (!isNull (names )) {
644643 frev (names , ScalarLogical (FALSE));
0 commit comments