From aa82b3a01a2487e4aeece0fb1de82a2e4819f3ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ne=C4=8Dada?= Date: Sat, 21 Mar 2020 16:31:41 +0200 Subject: [PATCH] Fix allocated array sizes. Former-commit-id: 7183f7f104df3af58d994d5e485b59cebb4365b3 --- qpms/vswf.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/qpms/vswf.c b/qpms/vswf.c index c319091..dd15023 100644 --- a/qpms/vswf.c +++ b/qpms/vswf.c @@ -611,14 +611,13 @@ csphvec_t qpms_eval_uvswf(const qpms_vswf_set_spec_t *bspec, const complex double *coeffs, const csph_t kr, const qpms_bessel_t btyp) { QPMS_UNTESTED; - const qpms_l_t lMax = bspec->lMax; complex double *cM = NULL, *cN = NULL, *cL = NULL, cL00 = 0; if (bspec->lMax_L > 0) - QPMS_CRASHING_CALLOC(cL, lMax, sizeof(complex double)); + QPMS_CRASHING_CALLOC(cL, bspec->n, sizeof(complex double)); if (bspec->lMax_M > 0) - QPMS_CRASHING_CALLOC(cM, lMax, sizeof(complex double)); + QPMS_CRASHING_CALLOC(cM, bspec->n, sizeof(complex double)); if (bspec->lMax_N > 0) - QPMS_CRASHING_CALLOC(cN, lMax, sizeof(complex double)); + QPMS_CRASHING_CALLOC(cN, bspec->n, sizeof(complex double)); for (size_t i = 0; i < bspec->n; ++i) { if (bspec->ilist[i] == 0) // L00, needs special care cL00 = coeffs[i]; @@ -644,7 +643,7 @@ csphvec_t qpms_eval_uvswf(const qpms_vswf_set_spec_t *bspec, } } } - csphvec_t result = qpms_eval_vswf_csph(kr, cL, cM, cN, lMax, btyp, bspec->norm); + csphvec_t result = qpms_eval_vswf_csph(kr, cL, cM, cN, bspec->lMax, btyp, bspec->norm); free(cM); free(cN); free(cL); if(cL00) result = csphvec_add(result,