diff --git a/NN/volume.c b/NN/volume.c
index cc8f0f944e0da18af7a35c45d57fb9fe97e7851c..22dd55aa13f2c097f5925ea9e039ed86bcb2db30 100644
--- a/NN/volume.c
+++ b/NN/volume.c
@@ -166,8 +166,8 @@ for (i=0;i<mm;i++)
 
 /* allocate memory */
 
-  ap = (float *) malloc(4*nm1*mm1);
-  bp = (float *) malloc(4*mm1);
+  ap = (float *) malloc((sizeof *a)*nm1*mm1);
+  bp = (float *) malloc((sizeof *b)*mm1);
 
 /* reduce a and b into ap and bp eliminating variable t and constraint i */