From: František Dvořák Date: Tue, 8 Jun 2010 17:50:03 +0000 (+0000) Subject: Notice allocation failures in database fetch. X-Git-Tag: glite-security-gsoap-plugin_R_2_1_2_1~23 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=80f487038c8aaa8d1b0f5e75f582a2048ba7ad6f;p=jra1mw.git Notice allocation failures in database fetch. --- diff --git a/org.glite.lbjp-common.db/src/db-mysql.c b/org.glite.lbjp-common.db/src/db-mysql.c index 3b525f6..ecec644 100644 --- a/org.glite.lbjp-common.db/src/db-mysql.c +++ b/org.glite.lbjp-common.db/src/db-mysql.c @@ -1007,14 +1007,24 @@ static int FetchRowSimple(glite_lbu_DBContextMysql ctx, MYSQL_RES *result, unsig for (i=0; istmt, binds) != 0) goto failedstmt; diff --git a/org.glite.lbjp-common.db/src/db-pg.c b/org.glite.lbjp-common.db/src/db-pg.c index c0acfc6..1581ac8 100644 --- a/org.glite.lbjp-common.db/src/db-pg.c +++ b/org.glite.lbjp-common.db/src/db-pg.c @@ -348,12 +348,20 @@ int glite_lbu_FetchRowPsql(glite_lbu_Statement stmt_gen, unsigned int maxn, unsi for (i = 0; i < n; i++) { /* sanity check for internal error (NULL when invalid row) */ s = psql_module.PQgetvalue(stmt->res, stmt->row, i) ? : ""; - results[i] = strdup(s); + if ((results[i] = strdup(s)) == NULL) + goto nomem; if (lengths) lengths[i] = strlen(s); } stmt->row++; return n; +nomem: + for (n = i, i = 0; i < n; i++) { + free(results[i]); + results[i] = NULL; + } + set_error(stmt->generic.ctx, ENOMEM, "insufficient memory for field data"); + return -1; }