davidsiaw / luacppinterface

A Simple C++ Interface to Lua
MIT License
167 stars 27 forks source link

Null reference issues #30

Closed davidsiaw closed 8 years ago

davidsiaw commented 8 years ago

There are some serious crashes that crop up when a string is extracted from a nil in Lua. This is bad. Will assign defaults to nilness or throw errors.

ziab commented 8 years ago

I though I addressed that issue before, exactly that crash issue was the reason why I tried to handle type conversion. Perhaps I don't the issue, can you post a code example?

@davidsiaw I have another bunch of changes locally, I'll send a review later.

davidsiaw commented 8 years ago

There is a branch msvc-tests. You can see the failing code is due to a memory error

davidsiaw commented 8 years ago

I removed the strict typing because it was causing more difficult problems.

lua.CreateFunction actually creates a Userdata that is callable (in order to be garbage collectable), if you try and Get<LuaFunction>, under the strict typing that fails (because userdata != function). This is actually a requirement of the library, and I use it quite a bit in my own programs. I have added tests to reflect that requirement.

Also, the typechecks were implemented as asserts in the constructors of the various datatypes. However, there are no checks for basic types std::string and std::wstring, so I kinda missed that out. I will add tests to make sure getting nil to an actual data type is sane.

I hate null.

davidsiaw commented 8 years ago

https://ci.appveyor.com/project/davidsiaw/luacppinterface/build/tests