added SDL_GetError() calls in NULL checks