[GRASS-SVN] r50348 - grass/branches/develbranch_6/lib/db/dbmi_client
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Jan 21 08:25:35 EST 2012
Author: mmetz
Date: 2012-01-21 05:25:35 -0800 (Sat, 21 Jan 2012)
New Revision: 50348
Modified:
grass/branches/develbranch_6/lib/db/dbmi_client/column.c
Log:
db lib: fix memory leak (backport from trunk)
Modified: grass/branches/develbranch_6/lib/db/dbmi_client/column.c
===================================================================
--- grass/branches/develbranch_6/lib/db/dbmi_client/column.c 2012-01-21 13:24:34 UTC (rev 50347)
+++ grass/branches/develbranch_6/lib/db/dbmi_client/column.c 2012-01-21 13:25:35 UTC (rev 50348)
@@ -39,6 +39,8 @@
dbColumn *column;
int ncol, cl, type;
+ type = -1;
+
db_init_string(&table_name);
db_set_string(&table_name, tab);
@@ -51,11 +53,13 @@
column = db_get_table_column(table, cl);
if (strcmp(db_get_column_name(column), col) == 0) {
type = db_get_column_sqltype(column);
- return type;
+ break;
}
}
- return -1;
+ db_free_table(table);
+
+ return type;
}
/*!
@@ -98,7 +102,7 @@
int db_get_column(dbDriver * Driver, const char *tname, const char *cname,
dbColumn ** Column)
{
- int i, ncols;
+ int i, ncols, ret;
dbTable *Table;
dbColumn *Col, *NCol;
dbString tabname;
@@ -112,6 +116,7 @@
}
*Column = NULL;
+ ret = DB_FAILED;
ncols = db_get_table_number_of_columns(Table);
G_debug(3, "ncol = %d", ncols);
@@ -138,8 +143,11 @@
NCol->update = Col->update;
*Column = NCol;
- return DB_OK;
+ ret = DB_OK;
+ break;
}
}
- return DB_OK;
+ db_free_table(Table);
+
+ return ret;
}
More information about the grass-commit
mailing list