}
static void
+weston_recorder_free(struct weston_recorder *recorder)
+{
+ if (recorder == NULL)
+ return;
+ free(recorder->rect);
+ free(recorder->tmpbuf);
+ free(recorder->frame);
+ free(recorder);
+}
+
+static void
weston_recorder_create(struct weston_output *output, const char *filename)
{
struct weston_compositor *compositor = output->compositor;
do_yflip = !!(compositor->capabilities & WESTON_CAP_CAPTURE_YFLIP);
recorder = malloc(sizeof *recorder);
-
if (recorder == NULL) {
weston_log("%s: out of memory\n", __func__);
return;
recorder->destroying = 0;
recorder->output = output;
+ if ((recorder->frame == NULL) || (recorder->rect == NULL)) {
+ weston_log("%s: out of memory\n", __func__);
+ weston_recorder_free(recorder);
+ return;
+ }
+
if (do_yflip)
recorder->tmpbuf = NULL;
else
break;
default:
weston_log("unknown recorder format\n");
- free(recorder->rect);
- free(recorder->tmpbuf);
- free(recorder->frame);
- free(recorder);
+ weston_recorder_free(recorder);
return;
}
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);
+ weston_recorder_free(recorder);
return;
}
{
wl_list_remove(&recorder->frame_listener.link);
close(recorder->fd);
- free(recorder->tmpbuf);
- free(recorder->frame);
- free(recorder->rect);
recorder->output->disable_planes--;
- free(recorder);
+ weston_recorder_free(recorder);
}
static void