-
-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
this can be NULL - segmentation fault #55
Comments
oh cool, this happens directly at start - I thought @emlai had tested this.. but I didn't either, when rebasing his changes ontop of mine, I only made sure it compiles :-/ I still hope that at least most of those I did that in #56, with those changes I can start and quit the game without crashes, and I can also start the first level and play a bit. I didn't test much more, though, so maybe there are other places where NULL-checks are needed. Could you try my fix? :-) |
Thanks for the fix!
I realized that if you look at these codes from the old C "functions" point of view (rather than from C++ "object oriented" point of view), all these checks actually make sense. They were probably added because they had a need for objects to be NULL sometimes.
|
are you sure you tested my fix from #56? the assert in SoundData.cpp:263 ( (if you are sure, can I have a backtrace?) |
Oops, sorry, my bad, I applied the wrong branch. Sorry for the confusion. Seems to be working fine now. :) |
Awesome, thanks for testing! :) |
I get a segmentation fault with the latest commits.
The assertion for (this != NULL) fails at Sources/Engine/Base/Anim.cpp:182. Ignoring this assertion, the code will proceed to crash.
lldb_log.txt
I looked at the commit that made the changes to this portion (5badefa). The compiler does not guard against function calls for NULL "objects" (the function executes anyway on inexistent objects). Therefore, even though the compiler is correct that 'this' pointer cannot be null in well-defined C++ code, the assumption that the code is well-defined in the first place is faulty.
I propose 2 different possible solutions:
Before
After
The second solution is probably "proper" C++.
Note: I looked through the rest of the changes in the commit and some portions will require more work than adding one if statement. (E.g.
CConsole::GetBufferSize()
requires the value of 1 to be returned ifthis == NULL
)The text was updated successfully, but these errors were encountered: