[GRASS-SVN] r70420 - grass-addons/grass7/raster/r.resamp.tps
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jan 23 23:40:32 PST 2017
Author: mmetz
Date: 2017-01-23 23:40:32 -0800 (Mon, 23 Jan 2017)
New Revision: 70420
Modified:
grass-addons/grass7/raster/r.resamp.tps/tps.c
Log:
r.resamp.tps: fix reallocation
Modified: grass-addons/grass7/raster/r.resamp.tps/tps.c
===================================================================
--- grass-addons/grass7/raster/r.resamp.tps/tps.c 2017-01-23 17:37:24 UTC (rev 70419)
+++ grass-addons/grass7/raster/r.resamp.tps/tps.c 2017-01-24 07:40:32 UTC (rev 70420)
@@ -947,6 +947,14 @@
G_free(m[i]);
G_free(m);
+ if (n_vars) {
+ G_free(apnts);
+ G_free(Bpnts);
+ for (i = 0; i < (palloc + 1); i++)
+ G_free(mpnts[i]);
+ G_free(mpnts);
+ }
+
palloc = pfound;
a = G_malloc((palloc + 1 + n_vars) * sizeof(double));
B = G_malloc((palloc + 1 + n_vars) * sizeof(double));
@@ -958,17 +966,13 @@
afull = a;
Bfull = B;
- G_free(apnts);
- G_free(Bpnts);
- for (i = 0; i < (palloc + 1); i++)
- G_free(mpnts[i]);
- G_free(mpnts);
-
- apnts = G_malloc((palloc + 1) * sizeof(double));
- Bpnts = G_malloc((palloc + 1) * sizeof(double));
- mpnts = G_malloc((palloc + 1) * sizeof(double *));
- for (i = 0; i < (palloc + 1); i++)
- mpnts[i] = G_malloc((palloc + 1) * sizeof(double));
+ if (n_vars) {
+ apnts = G_malloc((palloc + 1) * sizeof(double));
+ Bpnts = G_malloc((palloc + 1) * sizeof(double));
+ mpnts = G_malloc((palloc + 1) * sizeof(double *));
+ for (i = 0; i < (palloc + 1); i++)
+ mpnts[i] = G_malloc((palloc + 1) * sizeof(double));
+ }
}
/* sort points */
More information about the grass-commit
mailing list