[GRASS-SVN] r54932 - grass/trunk/lib/vector/diglib
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Feb 5 07:04:57 PST 2013
Author: mmetz
Date: 2013-02-05 07:04:57 -0800 (Tue, 05 Feb 2013)
New Revision: 54932
Modified:
grass/trunk/lib/vector/diglib/cindex.c
grass/trunk/lib/vector/diglib/cindex_rw.c
Log:
diglib: fix cidx memory leaks
Modified: grass/trunk/lib/vector/diglib/cindex.c
===================================================================
--- grass/trunk/lib/vector/diglib/cindex.c 2013-02-05 14:34:22 UTC (rev 54931)
+++ grass/trunk/lib/vector/diglib/cindex.c 2013-02-05 15:04:57 UTC (rev 54932)
@@ -48,7 +48,7 @@
G_debug(2, "dig_cidx_free()");
for (i = 0; i < Plus->n_cidx; i++) {
- ci = &(Plus->cidx[0]);
+ ci = &(Plus->cidx[i]);
G_free(ci->cat);
ci->cat = NULL;
ci->field = ci->n_cats = ci->a_cats = ci->n_types = 0;
Modified: grass/trunk/lib/vector/diglib/cindex_rw.c
===================================================================
--- grass/trunk/lib/vector/diglib/cindex_rw.c 2013-02-05 14:34:22 UTC (rev 54931)
+++ grass/trunk/lib/vector/diglib/cindex_rw.c 2013-02-05 15:04:57 UTC (rev 54932)
@@ -188,9 +188,11 @@
return (-1);
/* alloc space */
- plus->a_cidx = plus->n_cidx;
- plus->cidx =
- (struct Cat_index *)G_malloc(plus->a_cidx * sizeof(struct Cat_index));
+ if (plus->a_cidx < plus->n_cidx) {
+ plus->a_cidx = plus->n_cidx;
+ plus->cidx =
+ (struct Cat_index *)G_realloc(plus->cidx, plus->a_cidx * sizeof(struct Cat_index));
+ }
for (i = 0; i < plus->n_cidx; i++) {
int t;
@@ -292,6 +294,7 @@
G_debug(3, "dig_read_cidx()");
+ dig_cidx_free(plus);
dig_cidx_init(plus);
dig_rewind(fp);
More information about the grass-commit
mailing list