RE: error, setjmp and exceptions
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: RE: error, setjmp and exceptions
- From: "Joshua Jensen" <jjensen@...>
- Date: 2003年12月18日 12:27:40 -0700
> This may be common knowledge, but I thought I'd mention it.
>
> Calling lua_error() from a C/C++ function can result in
> leaked resources. This can be more subtle in C++ than in C.
>
> int func( lua_State* L )
> {
> std::vector< int > v;
> ...
> lua_error( L );
> return 0;
> }
>
> The vector's destructor never gets called and its memory is leaked.
I've run into this SO many times. I'm not sure if it is doable, but perhaps
lua_error() should set a flag for the error condition and only fire when the
Lua VM is back in control?
Josh