mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2026-05-05 01:48:00 +02:00
screenshooter: check for NULL malloc and fix memleaks
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
This commit is contained in:
parent
f05645b30e
commit
13708a4d67
1 changed files with 12 additions and 1 deletions
|
|
@ -190,7 +190,7 @@ screenshooter_shoot(struct wl_client *client,
|
|||
}
|
||||
if (!wl_shm_buffer_get(buffer->resource))
|
||||
return;
|
||||
|
||||
|
||||
buffer->shm_buffer = wl_shm_buffer_get(buffer->resource);
|
||||
buffer->width = wl_shm_buffer_get_width(buffer->shm_buffer);
|
||||
buffer->height = wl_shm_buffer_get_height(buffer->shm_buffer);
|
||||
|
|
@ -428,6 +428,11 @@ weston_recorder_create(struct weston_output *output, const char *filename)
|
|||
|
||||
recorder = malloc(sizeof *recorder);
|
||||
|
||||
if (recorder == NULL) {
|
||||
weston_log("%s: out of memory\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
stride = output->current_mode->width;
|
||||
size = stride * 4 * output->current_mode->height;
|
||||
recorder->frame = zalloc(size);
|
||||
|
|
@ -454,6 +459,9 @@ weston_recorder_create(struct weston_output *output, const char *filename)
|
|||
break;
|
||||
default:
|
||||
weston_log("unknown recorder format\n");
|
||||
free(recorder->rect);
|
||||
free(recorder->tmpbuf);
|
||||
free(recorder->frame);
|
||||
free(recorder);
|
||||
return;
|
||||
}
|
||||
|
|
@ -463,6 +471,9 @@ weston_recorder_create(struct weston_output *output, const char *filename)
|
|||
|
||||
if (recorder->fd < 0) {
|
||||
weston_log("problem opening output file %s: %m\n", filename);
|
||||
free(recorder->rect);
|
||||
free(recorder->tmpbuf);
|
||||
free(recorder->frame);
|
||||
free(recorder);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue