Below is a simple patch for the netcdf problem.  The trick is that when space for fname was being allocated, datadir hadn't been assigned a value yet.  A few lines later, when datadir was filled using getenv("DXDATA"), fname was overrunning it's allocated memory.  I can't believe I've been fighting for a month to find a 1-line bug!
 
amf
 
 
*** import_ncdf-old.c   Thu Mar 02 09:29:18 EST 2000
--- import_ncdf.c       Thu Mar 02 14:36:23 EST 2000
***************
*** 470,475 ****
--- 470,476 ----
       * space for trailing /, .nc, trailing 0 and some slop
       */
 
+     datadir = (char *)getenv("DXDATA");
      fname = (char *)DXAllocateLocalZero((datadir ? strlen(datadir) : 0) +
                                        strlen(filename) + XTRA);
      if (!fname)
***************
*** 483,489 ****
        return IMPORT_STAT_NOT_FOUND;
      }
 
-     datadir = (char *)getenv("DXDATA");
      if (!datadir)
        goto error;
 
--- 484,489 ----

Reply via email to