mirror of https://github.com/encounter/SDL.git
kmsdrm: Add missing checks after SDL_calloc() calls.
This commit is contained in:
parent
ad9ec8b363
commit
b1ea0be865
|
@ -545,6 +545,9 @@ setup_plane(_THIS, struct plane **plane, uint32_t plane_type)
|
||||||
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
|
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
|
||||||
|
|
||||||
*plane = SDL_calloc(1, sizeof(**plane));
|
*plane = SDL_calloc(1, sizeof(**plane));
|
||||||
|
if (!(*plane)) {
|
||||||
|
return SDL_OutOfMemory();
|
||||||
|
}
|
||||||
|
|
||||||
/* Get plane ID. */
|
/* Get plane ID. */
|
||||||
plane_id = get_plane_id(_this, plane_type);
|
plane_id = get_plane_id(_this, plane_type);
|
||||||
|
@ -561,10 +564,14 @@ setup_plane(_THIS, struct plane **plane, uint32_t plane_type)
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
(*plane)->props = KMSDRM_drmModeObjectGetProperties(viddata->drm_fd,
|
(*plane)->props = KMSDRM_drmModeObjectGetProperties(viddata->drm_fd,
|
||||||
(*plane)->plane->plane_id, DRM_MODE_OBJECT_PLANE);
|
(*plane)->plane->plane_id, DRM_MODE_OBJECT_PLANE);
|
||||||
|
|
||||||
(*plane)->props_info = SDL_calloc((*plane)->props->count_props,
|
(*plane)->props_info = SDL_calloc((*plane)->props->count_props,
|
||||||
sizeof(*(*plane)->props_info));
|
sizeof(*(*plane)->props_info));
|
||||||
|
|
||||||
|
if ( !((*plane)->props_info) ) {
|
||||||
|
SDL_OutOfMemory();
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < (*plane)->props->count_props; i++) {
|
for (i = 0; i < (*plane)->props->count_props; i++) {
|
||||||
(*plane)->props_info[i] = KMSDRM_drmModeGetProperty(viddata->drm_fd,
|
(*plane)->props_info[i] = KMSDRM_drmModeGetProperty(viddata->drm_fd,
|
||||||
(*plane)->props->props[i]);
|
(*plane)->props->props[i]);
|
||||||
|
@ -876,7 +883,6 @@ KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo)
|
||||||
/* Create a structure that contains the info about framebuffer
|
/* Create a structure that contains the info about framebuffer
|
||||||
that we need to use it. */
|
that we need to use it. */
|
||||||
fb_info = (KMSDRM_FBInfo *)SDL_calloc(1, sizeof(KMSDRM_FBInfo));
|
fb_info = (KMSDRM_FBInfo *)SDL_calloc(1, sizeof(KMSDRM_FBInfo));
|
||||||
|
|
||||||
if (!fb_info) {
|
if (!fb_info) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1139,9 +1145,16 @@ KMSDRM_VideoInit(_THIS)
|
||||||
SDL_VideoDisplay display = {0};
|
SDL_VideoDisplay display = {0};
|
||||||
|
|
||||||
dispdata = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData));
|
dispdata = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData));
|
||||||
|
if (!dispdata) {
|
||||||
|
return SDL_OutOfMemory();
|
||||||
|
}
|
||||||
|
|
||||||
dispdata->display_plane = SDL_calloc(1, sizeof(*dispdata->display_plane));
|
dispdata->display_plane = SDL_calloc(1, sizeof(*dispdata->display_plane));
|
||||||
dispdata->crtc = SDL_calloc(1, sizeof(*dispdata->crtc));
|
dispdata->crtc = SDL_calloc(1, sizeof(*dispdata->crtc));
|
||||||
dispdata->connector = SDL_calloc(1, sizeof(*dispdata->connector));
|
dispdata->connector = SDL_calloc(1, sizeof(*dispdata->connector));
|
||||||
|
if (!(dispdata->display_plane) || !(dispdata->crtc) || !(dispdata->connector)) {
|
||||||
|
return SDL_OutOfMemory();
|
||||||
|
}
|
||||||
|
|
||||||
dispdata->atomic_flags = 0;
|
dispdata->atomic_flags = 0;
|
||||||
dispdata->atomic_req = NULL;
|
dispdata->atomic_req = NULL;
|
||||||
|
@ -1151,10 +1164,6 @@ KMSDRM_VideoInit(_THIS)
|
||||||
dispdata->dumb_buffer = NULL;
|
dispdata->dumb_buffer = NULL;
|
||||||
dispdata->modeset_pending = SDL_FALSE;
|
dispdata->modeset_pending = SDL_FALSE;
|
||||||
|
|
||||||
if (!dispdata) {
|
|
||||||
return SDL_OutOfMemory();
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "KMSDRM_VideoInit()");
|
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "KMSDRM_VideoInit()");
|
||||||
|
|
||||||
/* Open /dev/dri/cardNN */
|
/* Open /dev/dri/cardNN */
|
||||||
|
@ -1337,6 +1346,11 @@ KMSDRM_VideoInit(_THIS)
|
||||||
|
|
||||||
dispdata->crtc->props_info = SDL_calloc(dispdata->crtc->props->count_props,
|
dispdata->crtc->props_info = SDL_calloc(dispdata->crtc->props->count_props,
|
||||||
sizeof(*dispdata->crtc->props_info));
|
sizeof(*dispdata->crtc->props_info));
|
||||||
|
|
||||||
|
if (!dispdata->crtc->props_info) {
|
||||||
|
ret = SDL_OutOfMemory();
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < dispdata->crtc->props->count_props; i++) {
|
for (i = 0; i < dispdata->crtc->props->count_props; i++) {
|
||||||
dispdata->crtc->props_info[i] = KMSDRM_drmModeGetProperty(viddata->drm_fd,
|
dispdata->crtc->props_info[i] = KMSDRM_drmModeGetProperty(viddata->drm_fd,
|
||||||
|
@ -1350,6 +1364,11 @@ KMSDRM_VideoInit(_THIS)
|
||||||
dispdata->connector->props_info = SDL_calloc(dispdata->connector->props->count_props,
|
dispdata->connector->props_info = SDL_calloc(dispdata->connector->props->count_props,
|
||||||
sizeof(*dispdata->connector->props_info));
|
sizeof(*dispdata->connector->props_info));
|
||||||
|
|
||||||
|
if (!dispdata->connector->props_info) {
|
||||||
|
ret = SDL_OutOfMemory();
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < dispdata->connector->props->count_props; i++) {
|
for (i = 0; i < dispdata->connector->props->count_props; i++) {
|
||||||
dispdata->connector->props_info[i] = KMSDRM_drmModeGetProperty(viddata->drm_fd,
|
dispdata->connector->props_info[i] = KMSDRM_drmModeGetProperty(viddata->drm_fd,
|
||||||
dispdata->connector->props->props[i]);
|
dispdata->connector->props->props[i]);
|
||||||
|
@ -1579,9 +1598,12 @@ KMSDRM_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
|
||||||
for (i = 0; i < conn->count_modes; i++) {
|
for (i = 0; i < conn->count_modes; i++) {
|
||||||
SDL_DisplayModeData *modedata = SDL_calloc(1, sizeof(SDL_DisplayModeData));
|
SDL_DisplayModeData *modedata = SDL_calloc(1, sizeof(SDL_DisplayModeData));
|
||||||
|
|
||||||
if (modedata) {
|
if (!modedata) {
|
||||||
modedata->mode_index = i;
|
SDL_OutOfMemory();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
modedata->mode_index = i;
|
||||||
|
|
||||||
mode.w = conn->modes[i].hdisplay;
|
mode.w = conn->modes[i].hdisplay;
|
||||||
mode.h = conn->modes[i].vdisplay;
|
mode.h = conn->modes[i].vdisplay;
|
||||||
|
@ -1651,13 +1673,17 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window)
|
||||||
|
|
||||||
/* Allocate window internal data */
|
/* Allocate window internal data */
|
||||||
windata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData));
|
windata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData));
|
||||||
|
if (!windata) {
|
||||||
|
SDL_OutOfMemory();
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
display = SDL_GetDisplayForWindow(window);
|
display = SDL_GetDisplayForWindow(window);
|
||||||
dispdata = display->driverdata;
|
dispdata = display->driverdata;
|
||||||
|
|
||||||
if (((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) ||
|
if (((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) ||
|
||||||
((window->flags & SDL_WINDOW_FULLSCREEN) == SDL_WINDOW_FULLSCREEN)) {
|
((window->flags & SDL_WINDOW_FULLSCREEN) == SDL_WINDOW_FULLSCREEN))
|
||||||
|
{
|
||||||
windata->src_w = dispdata->mode.hdisplay;
|
windata->src_w = dispdata->mode.hdisplay;
|
||||||
windata->src_h = dispdata->mode.vdisplay;
|
windata->src_h = dispdata->mode.vdisplay;
|
||||||
windata->output_w = dispdata->mode.hdisplay;
|
windata->output_w = dispdata->mode.hdisplay;
|
||||||
|
|
Loading…
Reference in New Issue