diff --git a/sim_video.c b/sim_video.c index e1e0c13c1..d320a5075 100644 --- a/sim_video.c +++ b/sim_video.c @@ -2613,7 +2613,13 @@ if (!fullname) if (1) { SDL_Surface *sshot = sim_end ? SDL_CreateRGBSurface(0, vptr->vid_width, vptr->vid_height, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000) : SDL_CreateRGBSurface(0, vptr->vid_width, vptr->vid_height, 32, 0x0000ff00, 0x000ff000, 0xff000000, 0x000000ff) ; - SDL_RenderReadPixels(vptr->vid_renderer, NULL, SDL_PIXELFORMAT_ARGB8888, sshot->pixels, sshot->pitch); + if (!sshot) + return SCPE_MEM; + if (SDL_RenderReadPixels(vptr->vid_renderer, NULL, SDL_PIXELFORMAT_ARGB8888, sshot->pixels, sshot->pitch) != 0) { + SDL_FreeSurface(sshot); + sim_printf ("Error creating screenshot: %s\n", SDL_GetError()); + return SCPE_ARG | SCPE_NOMESSAGE; + } #if defined(HAVE_LIBPNG) if (!match_ext (filename, "bmp")) { sprintf (fullname, "%s%s", filename, match_ext (filename, "png") ? "" : ".png"); @@ -2663,6 +2669,8 @@ else { } strncpy (name, _screenshot_filename, n); for (vptr = &vid_first; vptr != NULL; vptr = vptr->next) { + if (vptr->vid_width == 0) + continue; if (vid_active > 1) sprintf (name + n, "%d%s", i++, extension); else