lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


It was thus said that the Great Andrew Gierth once stated:
> >>>>> "Sean" == Sean Conner <sean@conman.org> writes:
> 
>  >> This is one of only two places in the whole Lua codebase, and is the
>  >> only library function, where __close is used (in both cases the code
>  >> just sets __close = __gc).
> 
>  Sean>   Now that I think about it, why have __close at all? Why not
>  Sean> have locals marked as <toclose> just call __gc upon leaving
>  Sean> scope?
> 
> 1) you might not want __close and __gc to do the same thing, and if you
>    do want it, it's trivial to assign the same function to both
> 
> 2) it would allow any object with __gc but not __close to be assigned to
>    a toclose variable, and that breaks a sandbox's control over error
>    handling

  How could it break a sandbox?  I mean, I can do:

	f = io.open(somevalidfile)
	f:__gc()

(that only works because the file's metatable has __index set to the
metatalbe, and it has the __gc method visible in it)

  -spc (Puzzled by the "break the sandbox" answers ... )