#! /bin/sh /usr/share/dpatch/dpatch-run
## 20_segfault.dpatch by  <domibel@sid1500>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: fix for nrrdHistoAxis() and "unu histax" for a bug that caused segfaults

@DPATCH@
diff -urNad teem-1.10.0.dfsg1~/src/nrrd/histogram.c teem-1.10.0.dfsg1/src/nrrd/histogram.c
--- teem-1.10.0.dfsg1~/src/nrrd/histogram.c	2008-12-31 17:58:25.000000000 -0500
+++ teem-1.10.0.dfsg1/src/nrrd/histogram.c	2008-12-31 17:58:42.000000000 -0500
@@ -403,14 +403,14 @@
      disaster */
   nrrdAxisInfoGet_nva(nin, nrrdAxisInfoSize, szIn);
   nrrdAxisInfoGet_nva(nout, nrrdAxisInfoSize, szOut);
-  memset(coordIn, 0, NRRD_DIM_MAX*sizeof(unsigned int));
+  memset(coordIn, 0, NRRD_DIM_MAX*sizeof(size_t));
   num = nrrdElementNumber(nin);
   for (I=0; I<num; I++) {
     /* get input nrrd value and compute its histogram index */
     val = nrrdDLookup[nin->type](nin->data, I);
     if (AIR_EXISTS(val) && AIR_IN_CL(range->min, val, range->max)) {
       hidx = airIndex(range->min, val, range->max, bins);
-      memcpy(coordOut, coordIn, nin->dim*sizeof(int));
+      memcpy(coordOut, coordIn, nin->dim*sizeof(size_t));
       coordOut[hax] = (unsigned int)hidx;
       NRRD_INDEX_GEN(hI, coordOut, szOut, nout->dim);
       count = nrrdDLookup[nout->type](nout->data, hI);
