Skip to content

Commit

Permalink
Do not allow installing AtExit functions more than once
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisJefferson authored and fingolfin committed Jun 28, 2018
1 parent 4394ec0 commit 1058408
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/oper.g
Original file line number Diff line number Diff line change
Expand Up @@ -1616,6 +1616,7 @@ end );
#F InstallAtExit( <func> ) . . . . . . . . . . function to call when exiting
##
BIND_GLOBAL( "InstallAtExit", function( func )
local f;
if not IS_FUNCTION(func) then
Error( "<func> must be a function" );
fi;
Expand All @@ -1624,6 +1625,13 @@ BIND_GLOBAL( "InstallAtExit", function( func )
Error( "<func> must accept zero arguments" );
fi;
fi;
# Return if function has already been installed
# Use this long form to support both List and AtomicList
for f in GAPInfo.AtExitFuncs do
if f = func then
return;
fi;
od;
ADD_LIST( GAPInfo.AtExitFuncs, func );
end );

Expand Down

0 comments on commit 1058408

Please sign in to comment.