summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-12-14 22:00:21 +0100
committerwm4 <wm4@nowhere>2014-12-14 22:00:21 +0100
commit399e2fec6ba70a22e8ab91a1ffb5b60c47778bd8 (patch)
treec604aadc1094b5bbd32fe9b435be4c9ba8009c1d /video
parent91b8a7f9943ed82b9e53178c798ce31a01174aa6 (diff)
downloadmpv-399e2fec6ba70a22e8ab91a1ffb5b60c47778bd8.tar.bz2
mpv-399e2fec6ba70a22e8ab91a1ffb5b60c47778bd8.tar.xz
vo_x11: check allocation errors
Avoids a crash if allocation fails.
Diffstat (limited to 'video')
-rw-r--r--video/out/vo_x11.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/video/out/vo_x11.c b/video/out/vo_x11.c
index 90e3eb52be..37e9607f0a 100644
--- a/video/out/vo_x11.c
+++ b/video/out/vo_x11.c
@@ -152,7 +152,7 @@ static int find_depth_from_visuals(struct vo *vo, Visual ** visual_return)
return bestvisual_depth;
}
-static void getMyXImage(struct priv *p, int foo)
+static bool getMyXImage(struct priv *p, int foo)
{
struct vo *vo = p->vo;
#if HAVE_SHM && HAVE_XEXT
@@ -210,6 +210,10 @@ shmemerror:
p->myximage[foo] =
XCreateImage(vo->x11->display, p->vinfo.visual, p->depth, ZPixmap,
0, NULL, p->image_width, p->image_height, 8, 0);
+ if (!p->myximage[foo]) {
+ MP_WARN(vo, "could not allocate image");
+ return false;
+ }
size_t sz = p->myximage[foo]->bytes_per_line * p->image_height + 32;
p->ImageDataOrig[foo] = calloc(1, sz);
p->myximage[foo]->data = p->ImageDataOrig[foo] + 16
@@ -218,6 +222,7 @@ shmemerror:
#if HAVE_SHM && HAVE_XEXT
}
#endif
+ return true;
}
static void freeMyXImage(struct priv *p, int foo)
@@ -340,8 +345,10 @@ static bool resize(struct vo *vo)
p->image_height = p->dst_h;
p->num_buffers = 2;
- for (int i = 0; i < p->num_buffers; i++)
- getMyXImage(p, i);
+ for (int i = 0; i < p->num_buffers; i++) {
+ if (!getMyXImage(p, i))
+ return -1;
+ }
const struct fmt2Xfmtentry_s *fmte = fmt2Xfmt;
while (fmte->mpfmt) {