[GRASS-dev] [GRASS GIS] #659: probable memory leak in v.surf.bspline

#659: probable memory leak in v.surf.bspline
----------------------------+-----------------------------------------------
Reporter: hamish | Owner: grass-dev@lists.osgeo.org
     Type: defect | Status: new
Priority: normal | Milestone: 6.4.0
Component: Vector | Version: 6.4.0 RCs
Keywords: v.surf.bspline | Platform: All
      Cpu: All |
----------------------------+-----------------------------------------------
Hi,

source:grass/trunk/vector/lidar/v.surf.bspline/main.c@#L364 has:

{{{
nrows = G_window_rows();
ncols = G_window_cols();

if (!G_alloc_matrix(nrows, ncols))
     G_fatal_error(_("Interpolation: The region resolution is too high: "
                    "%d cells. Consider to change it."), nrows * ncols);
}}}

is that a rather big memory leak? should it be like:

{{{
raster_matrix = G_alloc_matrix(nrows, ncols);

if (!raster_matrix)
     G_fatal_error(...);
else
     G_free_matrix(raster_matrix);
}}}

?

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/659&gt;
GRASS GIS <http://grass.osgeo.org>

#659: probable memory leak in v.surf.bspline
---------------------+------------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: closed
  Priority: normal | Milestone: 6.4.0
Component: Vector | Version: 6.4.0 RCs
Resolution: fixed | Keywords: v.surf.bspline
  Platform: All | Cpu: All
---------------------+------------------------------------------------------
Changes (by mmetz):

  * status: new => closed
  * resolution: => fixed

Comment:

Right, raster_matrix was allocated twice for some obscure reason. Fixed in
all branches with the recent overhaul of the lidar tools.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/659#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

GRASS GIS wrote:

#659: probable memory leak in v.surf.bspline
---------------------+------------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: closed Priority: normal | Milestone: 6.4.0 Component: Vector | Version: 6.4.0 RCs Resolution: fixed | Keywords: v.surf.bspline Platform: All | Cpu: All ---------------------+------------------------------------------------------
Changes (by mmetz):

  * status: new => closed
  * resolution: => fixed

Comment:

Right, raster_matrix was allocated twice for some obscure reason. Fixed in
all branches with the recent overhaul of the lidar tools.
  

BTW, fixed are also all the other memory leaks in some other lidar tools when accessing the auxiliary table (db_free_string() was missing).