Bug 1168480 - Fix potential leaks in qcms_transform_create. r=seth
authorDavid Major <dmajor@mozilla.com>
Tue, 26 May 2015 22:18:55 -0400
changeset 245767 d03ac97fabfa844d99d3560e80779bb5f3c9c849
parent 245766 82a7ea7ce995015a6d98494e25cdf55a6d28594d
child 245768 a19fd434d22a8ad69e59abc194049bce6b48794a
push id28816
push userkwierso@gmail.com
push dateThu, 28 May 2015 00:03:18 +0000
treeherdermozilla-central@8707d35414f4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersseth
bugs1168480
milestone41.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1168480 - Fix potential leaks in qcms_transform_create. r=seth
gfx/qcms/transform.c
--- a/gfx/qcms/transform.c
+++ b/gfx/qcms/transform.c
@@ -1215,17 +1215,17 @@ qcms_transform* qcms_transform_create(
 
         qcms_transform *transform = transform_alloc();
         if (!transform) {
 		return NULL;
 	}
 	if (out_type != QCMS_DATA_RGB_8 &&
                 out_type != QCMS_DATA_RGBA_8) {
             assert(0 && "output type");
-	    transform_free(transform);
+	    qcms_transform_release(transform);
             return NULL;
         }
 
 	if (out->output_table_r &&
 			out->output_table_g &&
 			out->output_table_b) {
 		precache = true;
 	}
@@ -1238,17 +1238,17 @@ qcms_transform* qcms_transform_create(
 		// Precache the transformation to a CLUT 33x33x33 in size.
 		// 33 is used by many profiles and works well in pratice. 
 		// This evenly divides 256 into blocks of 8x8x8.
 		// TODO For transforming small data sets of about 200x200 or less
 		// precaching should be avoided.
 		qcms_transform *result = qcms_transform_precacheLUT_float(transform, in, out, 33, in_type);
 		if (!result) {
             		assert(0 && "precacheLUT failed");
-			transform_free(transform);
+			qcms_transform_release(transform);
 			return NULL;
 		}
 		return result;
 	}
 
 	if (precache) {
 		transform->output_table_r = precache_reference(out->output_table_r);
 		transform->output_table_g = precache_reference(out->output_table_g);
@@ -1268,17 +1268,17 @@ qcms_transform* qcms_transform_create(
 	}
 
         if (in->color_space == RGB_SIGNATURE) {
 		struct matrix in_matrix, out_matrix, result;
 
 		if (in_type != QCMS_DATA_RGB_8 &&
                     in_type != QCMS_DATA_RGBA_8){
                 	assert(0 && "input type");
-			transform_free(transform);
+			qcms_transform_release(transform);
                 	return NULL;
             	}
 		if (precache) {
 #ifdef X86
 		    if (sse_version_available() >= 2) {
 			    if (in_type == QCMS_DATA_RGB_8)
 				    transform->transform_fn = qcms_transform_data_rgb_out_lut_sse2;
 			    else
@@ -1358,17 +1358,17 @@ qcms_transform* qcms_transform_create(
 		transform->matrix[0][2] = result.m[2][0];
 		transform->matrix[1][2] = result.m[2][1];
 		transform->matrix[2][2] = result.m[2][2];
 
 	} else if (in->color_space == GRAY_SIGNATURE) {
 		if (in_type != QCMS_DATA_GRAY_8 &&
 				in_type != QCMS_DATA_GRAYA_8){
 			assert(0 && "input type");
-			transform_free(transform);
+			qcms_transform_release(transform);
 			return NULL;
 		}
 
 		transform->input_gamma_table_gray = build_input_gamma_table(in->grayTRC);
 		if (!transform->input_gamma_table_gray) {
 			qcms_transform_release(transform);
 			return NO_MEM_TRANSFORM;
 		}
@@ -1383,17 +1383,17 @@ qcms_transform* qcms_transform_create(
 			if (in_type == QCMS_DATA_GRAY_8) {
 				transform->transform_fn = qcms_transform_data_gray_out_lut;
 			} else {
 				transform->transform_fn = qcms_transform_data_graya_out_lut;
 			}
 		}
 	} else {
 		assert(0 && "unexpected colorspace");
-		transform_free(transform);
+		qcms_transform_release(transform);
 		return NULL;
 	}
 	return transform;
 }
 
 #if defined(__GNUC__) && !defined(__x86_64__) && !defined(__amd64__)
 /* we need this to avoid crashes when gcc assumes the stack is 128bit aligned */
 __attribute__((__force_align_arg_pointer__))