{"action":"created","issue":{"url":"https://api.github.com/repos/rcgordon/Serious-Engine/issues/55","repository_url":"https://api.github.com/repos/rcgordon/Serious-Engine","labels_url":"https://api.github.com/repos/rcgordon/Serious-Engine/issues/55/labels{/name}","comments_url":"https://api.github.com/repos/rcgordon/Serious-Engine/issues/55/comments","events_url":"https://api.github.com/repos/rcgordon/Serious-Engine/issues/55/events","html_url":"https://github.com/rcgordon/Serious-Engine/issues/55","id":157460547,"number":55,"title":"this can be NULL - segmentation fault","user":{"login":"yamgent","id":3168908,"avatar_url":"https://avatars.githubusercontent.com/u/3168908?v=3","gravatar_id":"","url":"https://api.github.com/users/yamgent","html_url":"https://github.com/yamgent","followers_url":"https://api.github.com/users/yamgent/followers","following_url":"https://api.github.com/users/yamgent/following{/other_user}","gists_url":"https://api.github.com/users/yamgent/gists{/gist_id}","starred_url":"https://api.github.com/users/yamgent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yamgent/subscriptions","organizations_url":"https://api.github.com/users/yamgent/orgs","repos_url":"https://api.github.com/users/yamgent/repos","events_url":"https://api.github.com/users/yamgent/events{/privacy}","received_events_url":"https://api.github.com/users/yamgent/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-05-30T08:58:59Z","updated_at":"2016-06-07T01:15:54Z","closed_at":null,"body":"I get a segmentation fault with the latest commits.\r\n\r\nThe assertion for (this != NULL) fails at [Sources/Engine/Base/Anim.cpp:182](https://github.com/DanielGibson/Serious-Engine/blob/5badefaf900165feb7196ee78343ceb5ba3d3a4a/Sources/Engine/Base/Anim.cpp#L182). Ignoring this assertion, the code will proceed to crash.\r\n\r\n[lldb_log.txt](https://github.com/rcgordon/Serious-Engine/files/289143/lldb_log.txt)\r\n\r\nI 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.\r\n\r\nI propose 2 different possible solutions:\r\n\r\n1. Either revert commit 5badefa, or\r\n2. Add a if statement to all affected method calls so that it checks that the object is not NULL first before calling its methods. I.e.\r\n\r\nBefore\r\n\r\n```\r\n// will call even if abc is NULL\r\nabc->CallFunction();\r\n```\r\n\r\nAfter\r\n```\r\n// now no longer calls when abc is NULL\r\nif (abc != NULL)\r\n    abc->CallFunction();\r\n```\r\n\r\nThe second solution is probably \"proper\" C++.\r\n\r\nNote: 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 if `this == NULL`)"},"comment":{"url":"https://api.github.com/repos/rcgordon/Serious-Engine/issues/comments/224135245","html_url":"https://github.com/rcgordon/Serious-Engine/issues/55#issuecomment-224135245","issue_url":"https://api.github.com/repos/rcgordon/Serious-Engine/issues/55","id":224135245,"user":{"login":"DanielGibson","id":1216493,"avatar_url":"https://avatars.githubusercontent.com/u/1216493?v=3","gravatar_id":"","url":"https://api.github.com/users/DanielGibson","html_url":"https://github.com/DanielGibson","followers_url":"https://api.github.com/users/DanielGibson/followers","following_url":"https://api.github.com/users/DanielGibson/following{/other_user}","gists_url":"https://api.github.com/users/DanielGibson/gists{/gist_id}","starred_url":"https://api.github.com/users/DanielGibson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanielGibson/subscriptions","organizations_url":"https://api.github.com/users/DanielGibson/orgs","repos_url":"https://api.github.com/users/DanielGibson/repos","events_url":"https://api.github.com/users/DanielGibson/events{/privacy}","received_events_url":"https://api.github.com/users/DanielGibson/received_events","type":"User","site_admin":false},"created_at":"2016-06-07T01:15:54Z","updated_at":"2016-06-07T01:15:54Z","body":"Awesome, thanks for testing! :)"}}
{"actor":{"display_login":"DanielGibson"}}