diff options
author | Calvin Lee <cyrus296@gmail.com> | 2017-08-15 07:56:47 +0200 |
---|---|---|
committer | Calvin Lee <cyrus296@gmail.com> | 2017-08-15 08:04:57 +0200 |
commit | 5cc7342606dbbd5e6932b39e6b1b5645164669bf (patch) | |
tree | f4cdef098650e5d0ac2f9ca3237f2f789db1d3fe /render | |
parent | 5ca88af557178c0081fd408ae008686b79d6dd9c (diff) |
Prevent alloc errors from crashing
Resolves #76
Diffstat (limited to 'render')
-rw-r--r-- | render/gles2/renderer.c | 6 | ||||
-rw-r--r-- | render/gles2/texture.c | 6 |
2 files changed, 8 insertions, 4 deletions
diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c index 75a47187..27f3d33e 100644 --- a/render/gles2/renderer.c +++ b/render/gles2/renderer.c @@ -240,8 +240,10 @@ static struct wlr_renderer_impl wlr_renderer_impl = { struct wlr_renderer *wlr_gles2_renderer_init(struct wlr_backend *backend) { init_globals(); - struct wlr_gles2_renderer *renderer = - calloc(1, sizeof(struct wlr_gles2_renderer)); + struct wlr_gles2_renderer *renderer; + if (!(renderer = calloc(1, sizeof(struct wlr_gles2_renderer)))) { + return NULL; + } wlr_renderer_init(&renderer->wlr_renderer, &wlr_renderer_impl); if (backend) { struct wlr_egl *egl = wlr_backend_get_egl(backend); diff --git a/render/gles2/texture.c b/render/gles2/texture.c index 1e80a8d6..041625fd 100644 --- a/render/gles2/texture.c +++ b/render/gles2/texture.c @@ -252,8 +252,10 @@ static struct wlr_texture_impl wlr_texture_impl = { }; struct wlr_texture *gles2_texture_init(struct wlr_egl *egl) { - struct wlr_gles2_texture *texture = - calloc(1, sizeof(struct wlr_gles2_texture)); + struct wlr_gles2_texture *texture; + if (!(texture = calloc(1, sizeof(struct wlr_gles2_texture)))) { + return NULL; + } wlr_texture_init(&texture->wlr_texture, &wlr_texture_impl); texture->egl = egl; return &texture->wlr_texture; |