diff options
author | Drew DeVault <sir@cmpwn.com> | 2017-08-15 12:21:58 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-15 12:21:58 -0400 |
commit | 27c13d621df7b38d04f8ffb3012aa977d1b9bb24 (patch) | |
tree | 4cf9539672adb77ddc6ac2110a6f4458b386e9a1 /render | |
parent | f60b53c6e3c91aefa432ce75deb89560a8e5c0d7 (diff) | |
parent | 5cc7342606dbbd5e6932b39e6b1b5645164669bf (diff) |
Merge pull request #88 from 4e554c4c/alloc_crashing
Prevent alloc errors from crashing
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 e63787d8..1f3c3eeb 100644 --- a/render/gles2/renderer.c +++ b/render/gles2/renderer.c @@ -241,8 +241,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 4eb79374..6bb93e4f 100644 --- a/render/gles2/texture.c +++ b/render/gles2/texture.c @@ -277,8 +277,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; |