From 12c8cf94f244b3fc1039e71c7a664b97a2045554 Mon Sep 17 00:00:00 2001 From: homm Date: Wed, 8 Jun 2016 03:45:08 +0300 Subject: [PATCH] replace calloc with remaining values emptying --- libImaging/Resample.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libImaging/Resample.c b/libImaging/Resample.c index d32fe63ae..23e39a2e4 100644 --- a/libImaging/Resample.c +++ b/libImaging/Resample.c @@ -102,10 +102,8 @@ ImagingPrecompute(int inSize, int outSize, struct filter *filterp, if (outSize > INT_MAX / (2 * sizeof(double))) return 0; - /* coefficient buffer. kmax elements for each of outSize pixels. - Only xmax number of coefficients are initialized (xmax <= kmax), - other coefficients should be 0, so we are using calloc. */ - kk = calloc(outSize * kmax, sizeof(double)); + /* coefficient buffer */ + kk = malloc(outSize * kmax * sizeof(double)); if ( ! kk) return 0; @@ -136,6 +134,10 @@ ImagingPrecompute(int inSize, int outSize, struct filter *filterp, if (ww != 0.0) k[x] /= ww; } + // Remaining values should stay empty if they are used despite of xmax. + for (; x < kmax; x++) { + k[x] = 0; + } xbounds[xx * 2 + 0] = xmin; xbounds[xx * 2 + 1] = xmax; }