Skip to content

Commit

Permalink
sdl: error: Fix crash on certain Windows environment
Browse files Browse the repository at this point in the history
Apparently caused by sdl.SetError(nil) but it doesn't
always happen.

See veandco#340

Signed-off-by: Lilis Iskandar <[email protected]>
  • Loading branch information
veeableful committed Jul 9, 2018
1 parent 83f2819 commit 04acf50
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sdl/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ package sdl
void GoSetError(const char *fmt) {
SDL_SetError("%s", fmt);
}
*/
// #include "sdl_wrapper.h"
import "C"
import "errors"

var emptyCString *C.char = C.CString("")

// SDL error codes with their corresponding predefined strings.
const (
ENOMEM ErrorCode = C.SDL_ENOMEM // out of memory
Expand Down Expand Up @@ -49,7 +52,7 @@ func SetError(err error) {
C.GoSetError(C.CString(err.Error()))
return
}
C.GoSetError(nil)
C.GoSetError(emptyCString)
}

// ClearError clears any previous error message.
Expand Down

0 comments on commit 04acf50

Please sign in to comment.