{"action":"created","issue":{"url":"https://api.github.com/repos/brson/rust-sdl/issues/155","labels_url":"https://api.github.com/repos/brson/rust-sdl/issues/155/labels{/name}","comments_url":"https://api.github.com/repos/brson/rust-sdl/issues/155/comments","events_url":"https://api.github.com/repos/brson/rust-sdl/issues/155/events","html_url":"https://github.com/brson/rust-sdl/pull/155","id":54016290,"number":155,"title":"Fixed sdl::get_error to not segfault","user":{"login":"TheNeikos","id":1631166,"avatar_url":"https://avatars.githubusercontent.com/u/1631166?v=3","gravatar_id":"","url":"https://api.github.com/users/TheNeikos","html_url":"https://github.com/TheNeikos","followers_url":"https://api.github.com/users/TheNeikos/followers","following_url":"https://api.github.com/users/TheNeikos/following{/other_user}","gists_url":"https://api.github.com/users/TheNeikos/gists{/gist_id}","starred_url":"https://api.github.com/users/TheNeikos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheNeikos/subscriptions","organizations_url":"https://api.github.com/users/TheNeikos/orgs","repos_url":"https://api.github.com/users/TheNeikos/repos","events_url":"https://api.github.com/users/TheNeikos/events{/privacy}","received_events_url":"https://api.github.com/users/TheNeikos/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-01-12T02:51:53Z","updated_at":"2015-01-16T06:40:46Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/brson/rust-sdl/pulls/155","html_url":"https://github.com/brson/rust-sdl/pull/155","diff_url":"https://github.com/brson/rust-sdl/pull/155.diff","patch_url":"https://github.com/brson/rust-sdl/pull/155.patch"},"body":"This one was a bit tricky as I am not sure what the initial version had tried\r\nto do. `SDL_GetError()` returns a constant char pointer. (`char const *`)\r\nHowever they are already in bytes. `c_str_to_bytes` expects a pointer to a\r\nc_str as seen here: [Rust Source](1)\r\n\r\nThis version seems safer to me as we do not transmute, and since SDL explicitely\r\nstates that those strings are fixed in memory this should not segfault.\r\n\r\n[1]: https://github.com/rust-lang/rust/blob/master/src/libstd/ffi/c_str.rs#L186"},"comment":{"url":"https://api.github.com/repos/brson/rust-sdl/issues/comments/70214519","html_url":"https://github.com/brson/rust-sdl/pull/155#issuecomment-70214519","issue_url":"https://api.github.com/repos/brson/rust-sdl/issues/155","id":70214519,"user":{"login":"TheNeikos","id":1631166,"avatar_url":"https://avatars.githubusercontent.com/u/1631166?v=3","gravatar_id":"","url":"https://api.github.com/users/TheNeikos","html_url":"https://github.com/TheNeikos","followers_url":"https://api.github.com/users/TheNeikos/followers","following_url":"https://api.github.com/users/TheNeikos/following{/other_user}","gists_url":"https://api.github.com/users/TheNeikos/gists{/gist_id}","starred_url":"https://api.github.com/users/TheNeikos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheNeikos/subscriptions","organizations_url":"https://api.github.com/users/TheNeikos/orgs","repos_url":"https://api.github.com/users/TheNeikos/repos","events_url":"https://api.github.com/users/TheNeikos/events{/privacy}","received_events_url":"https://api.github.com/users/TheNeikos/received_events","type":"User","site_admin":false},"created_at":"2015-01-16T06:40:46Z","updated_at":"2015-01-16T06:40:46Z","body":"Okay, I have switched to using `c_str_to_bytes` I also tested it and it seems to work as intended."}}