From 98a50600acbf591c5ec1f0850f2b00d5420bb300 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Mon, 17 Jul 2006 18:31:24 +0000 Subject: - avoid crashes when init_yuv_planes has one of its allocations failing See http://bugzilla.gnome.org/show_bug.cgi?id=338833 CVS patchset: 8135 CVS date: 2006/07/17 18:31:24 --- src/xine-utils/color.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/xine-utils/color.c b/src/xine-utils/color.c index c667c678c..c5d42be9d 100644 --- a/src/xine-utils/color.c +++ b/src/xine-utils/color.c @@ -61,7 +61,7 @@ * instructions), these macros will automatically map to those special * instructions. * - * $Id: color.c,v 1.29 2006/06/20 00:35:08 dgp85 Exp $ + * $Id: color.c,v 1.30 2006/07/17 18:31:24 hadess Exp $ */ #include "xine_internal.h" @@ -164,6 +164,8 @@ void init_yuv_planes(yuv_planes_t *yuv_planes, int width, int height) { int plane_size; + memset (yuv_planes, 0, sizeof (yuv_planes)); + yuv_planes->row_width = width; yuv_planes->row_count = height; plane_size = yuv_planes->row_width * yuv_planes->row_count; @@ -179,9 +181,12 @@ void init_yuv_planes(yuv_planes_t *yuv_planes, int width, int height) { * This frees the memory used by the YUV planes. */ void free_yuv_planes(yuv_planes_t *yuv_planes) { - free(yuv_planes->y); - free(yuv_planes->u); - free(yuv_planes->v); + if (yuv_planes->y) + free(yuv_planes->y); + if (yuv_planes->u) + free(yuv_planes->u); + if (yuv_planes->v) + free(yuv_planes->v); } /* -- cgit v1.2.3