Index: trunk/stac/src/stacScales.c
===================================================================
--- trunk/stac/src/stacScales.c	(revision 5745)
+++ trunk/stac/src/stacScales.c	(revision 6887)
@@ -19,4 +19,6 @@
     psVector *values = psVectorAlloc(numSamples + 1, PS_TYPE_F32); // Vector containing sub-sample
     psVector *mask = psVectorAlloc(numSamples + 1, PS_TYPE_U8); // Mask for sample
+    values->n = numSamples + 1;
+    mask->n = numSamples + 1;
 
     int offset = 0;                     // Offset from start of the row
@@ -84,4 +86,5 @@
     } else {
         scales = psVectorAlloc(images->n, PS_TYPE_F32);
+        scales->n = images->n;
         *scalesPtr = scales;
     }
@@ -93,4 +96,5 @@
     } else {
         offsets = psVectorAlloc(images->n, PS_TYPE_F32);
+        offsets->n = images->n;
         *offsetsPtr = offsets;
     }
@@ -122,4 +126,5 @@
         // Transform the stellar positions to match the transformed reference frame
         psArray *starCoordsTransformed = psArrayAlloc(starCoords->n); // Transformed positions
+        starCoordsTransformed->n = starCoords->n;
         // Fix up difference between map and output frame
         starMap->x->coeff[0][0] -= xMapDiff;
@@ -132,4 +137,6 @@
         psArray *stars = psArrayAlloc(images->n); // Array of stellar photometry vectors
         psArray *masks = psArrayAlloc(images->n); // Array of masks for stars
+        stars->n = images->n;
+        masks->n = images->n;
 
         // Set scales relative to the first image
@@ -144,4 +151,6 @@
             psVector *photometry = psVectorAlloc(starCoords->n, PS_TYPE_F32); // Photometry of the stars
             psVector *mask = psVectorAlloc(starCoords->n, PS_TYPE_U8); // Mask for the photometry
+            photometry->n = starCoords->n;
+            mask->n = starCoords->n;
             for (int j = 0; j < starCoordsTransformed->n; j++) {
                 psPlane *coords = starCoordsTransformed->data[j]; // The coordinates of the star
