mirror of
https://github.com/Ryujinx/SDL.git
synced 2025-01-26 21:01:08 +00:00
kmsdrm: Fixed crashes if allocating memory failed.
This commit is contained in:
parent
b8a7dd7788
commit
f216b446aa
|
@ -102,6 +102,9 @@ KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fb_info = KMSDRM_FBFromBO(_this, wdata->next_bo);
|
fb_info = KMSDRM_FBFromBO(_this, wdata->next_bo);
|
||||||
|
if (fb_info == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (_this->egl_data->egl_swapinterval == 0) {
|
if (_this->egl_data->egl_swapinterval == 0) {
|
||||||
/* Swap buffers instantly, possible tearing */
|
/* Swap buffers instantly, possible tearing */
|
||||||
/* SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "drmModeSetCrtc(%d, %u, %u, 0, 0, &%u, 1, &%ux%u@%u)",
|
/* SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "drmModeSetCrtc(%d, %u, %u, 0, 0, &%u, 1, &%ux%u@%u)",
|
||||||
|
|
|
@ -199,6 +199,10 @@ KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo)
|
||||||
|
|
||||||
/* Here a new DRM FB must be created */
|
/* Here a new DRM FB must be created */
|
||||||
fb_info = (KMSDRM_FBInfo *)SDL_calloc(1, sizeof(KMSDRM_FBInfo));
|
fb_info = (KMSDRM_FBInfo *)SDL_calloc(1, sizeof(KMSDRM_FBInfo));
|
||||||
|
if (fb_info == NULL) {
|
||||||
|
SDL_OutOfMemory();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
fb_info->drm_fd = vdata->drm_fd;
|
fb_info->drm_fd = vdata->drm_fd;
|
||||||
|
|
||||||
w = KMSDRM_gbm_bo_get_width(bo);
|
w = KMSDRM_gbm_bo_get_width(bo);
|
||||||
|
@ -280,6 +284,10 @@ KMSDRM_VideoInit(_THIS)
|
||||||
|
|
||||||
/* Open /dev/dri/cardNN */
|
/* Open /dev/dri/cardNN */
|
||||||
devname = (char *) SDL_calloc(1, 16);
|
devname = (char *) SDL_calloc(1, 16);
|
||||||
|
if (devname == NULL) {
|
||||||
|
ret = SDL_OutOfMemory();
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
SDL_snprintf(devname, 16, "/dev/dri/card%d", vdata->devindex);
|
SDL_snprintf(devname, 16, "/dev/dri/card%d", vdata->devindex);
|
||||||
vdata->drm_fd = open(devname, O_RDWR | O_CLOEXEC);
|
vdata->drm_fd = open(devname, O_RDWR | O_CLOEXEC);
|
||||||
SDL_free(devname);
|
SDL_free(devname);
|
||||||
|
|
Loading…
Reference in a new issue