summaryrefslogtreecommitdiff
path: root/test/pdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2007-12-17 22:37:31 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2007-12-20 14:13:12 +0000
commited3fccec01257a7c52694150cda9ea1059c33585 (patch)
treee35eab0e13827597bcb6eda9dd800189a98b3bad /test/pdiff
parentdf938a515bd59138421b6ab4419966805d027b52 (diff)
downloadcairo-ed3fccec01257a7c52694150cda9ea1059c33585.tar.gz
[pdiff] Avoid the memleak for small surfaces.
Allocate the arrays after the guard against small surfaces to avoid leaking them.
Diffstat (limited to 'test/pdiff')
-rw-r--r--test/pdiff/pdiff.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/test/pdiff/pdiff.c b/test/pdiff/pdiff.c
index 4f3226db3..3f472f3b9 100644
--- a/test/pdiff/pdiff.c
+++ b/test/pdiff/pdiff.c
@@ -257,19 +257,19 @@ pdiff_compare (cairo_surface_t *surface_a,
unsigned int i;
/* assuming colorspaces are in Adobe RGB (1998) convert to XYZ */
- float *aX = xmalloc (dim * sizeof (float));
- float *aY = xmalloc (dim * sizeof (float));
- float *aZ = xmalloc (dim * sizeof (float));
- float *bX = xmalloc (dim * sizeof (float));
- float *bY = xmalloc (dim * sizeof (float));
- float *bZ = xmalloc (dim * sizeof (float));
- float *aLum = xmalloc (dim * sizeof (float));
- float *bLum = xmalloc (dim * sizeof (float));
-
- float *aA = xmalloc (dim * sizeof (float));
- float *bA = xmalloc (dim * sizeof (float));
- float *aB = xmalloc (dim * sizeof (float));
- float *bB = xmalloc (dim * sizeof (float));
+ float *aX;
+ float *aY;
+ float *aZ;
+ float *bX;
+ float *bY;
+ float *bZ;
+ float *aLum;
+ float *bLum;
+
+ float *aA;
+ float *bA;
+ float *aB;
+ float *bB;
unsigned int x, y, w, h;
@@ -289,6 +289,20 @@ pdiff_compare (cairo_surface_t *surface_a,
if (w < 3 || h < 3) /* too small for the Laplacian convolution */
return -1;
+ aX = xmalloc (dim * sizeof (float));
+ aY = xmalloc (dim * sizeof (float));
+ aZ = xmalloc (dim * sizeof (float));
+ bX = xmalloc (dim * sizeof (float));
+ bY = xmalloc (dim * sizeof (float));
+ bZ = xmalloc (dim * sizeof (float));
+ aLum = xmalloc (dim * sizeof (float));
+ bLum = xmalloc (dim * sizeof (float));
+
+ aA = xmalloc (dim * sizeof (float));
+ bA = xmalloc (dim * sizeof (float));
+ aB = xmalloc (dim * sizeof (float));
+ bB = xmalloc (dim * sizeof (float));
+
for (y = 0; y < h; y++) {
for (x = 0; x < w; x++) {
float r, g, b, l;