summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXiang, Haihao <haihao.xiang@intel.com>2013-03-07 13:52:12 +0800
committerXiang, Haihao <haihao.xiang@intel.com>2013-03-15 15:45:28 +0800
commitc006f66fae9b3d9bf2144050eb077d6c990f0282 (patch)
tree796f4cfc52c4893e180fd98406f3ce1c04ce28af
parent9055aab4b75afcbf7c485a2abeff80537986a887 (diff)
downloadvaapi-intel-driver-c006f66fae9b3d9bf2144050eb077d6c990f0282.tar.gz
vaapi-intel-driver-c006f66fae9b3d9bf2144050eb077d6c990f0282.tar.bz2
vaapi-intel-driver-c006f66fae9b3d9bf2144050eb077d6c990f0282.zip
Release resource if failed to initialize display attributes
Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
-rwxr-xr-xsrc/i965_drv_video.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c
index 6586ac3..6c45900 100755
--- a/src/i965_drv_video.c
+++ b/src/i965_drv_video.c
@@ -2067,6 +2067,18 @@ get_display_attribute(VADriverContextP ctx, VADisplayAttribType type)
return NULL;
}
+static void
+i965_display_attributes_terminate(VADriverContextP ctx)
+{
+ struct i965_driver_data * const i965 = i965_driver_data(ctx);
+
+ if (i965->display_attributes) {
+ free(i965->display_attributes);
+ i965->display_attributes = NULL;
+ i965->num_display_attributes = 0;
+ }
+}
+
static bool
i965_display_attributes_init(VADriverContextP ctx)
{
@@ -2076,7 +2088,7 @@ i965_display_attributes_init(VADriverContextP ctx)
i965->display_attributes = malloc(
i965->num_display_attributes * sizeof(i965->display_attributes[0]));
if (!i965->display_attributes)
- return false;
+ goto error;
memcpy(
i965->display_attributes,
@@ -2085,21 +2097,14 @@ i965_display_attributes_init(VADriverContextP ctx)
);
i965->rotation_attrib = get_display_attribute(ctx, VADisplayAttribRotation);
- if (!i965->rotation_attrib)
- return false;
+ if (!i965->rotation_attrib) {
+ goto error;
+ }
return true;
-}
-
-static void
-i965_display_attributes_terminate(VADriverContextP ctx)
-{
- struct i965_driver_data * const i965 = i965_driver_data(ctx);
- if (i965->display_attributes) {
- free(i965->display_attributes);
- i965->display_attributes = NULL;
- i965->num_display_attributes = 0;
- }
+error:
+ i965_display_attributes_terminate(ctx);
+ return false;
}
/*