diff options
author | Michael Meskes <meskes@postgresql.org> | 2015-02-05 15:12:34 +0100 |
---|---|---|
committer | Michael Meskes <meskes@postgresql.org> | 2015-02-05 15:12:34 +0100 |
commit | 5ee5bc387319b9ac33083bacebd3ab7046666328 (patch) | |
tree | e91d18d6b121852c795ef1c90ba40087be3c3f71 /src/interfaces/ecpg/ecpglib/execute.c | |
parent | d88976cfa1302e8dccdcbfe55e9e29faee8c0cdf (diff) | |
download | postgresql-5ee5bc387319b9ac33083bacebd3ab7046666328.tar.gz postgresql-5ee5bc387319b9ac33083bacebd3ab7046666328.zip |
This routine was calling ecpg_alloc to allocate to memory but did not
actually check the returned pointer allocated, potentially NULL which
could be the result of a malloc call.
Issue noted by Coverity, fixed by Michael Paquier <michael@otacoo.com>
Diffstat (limited to 'src/interfaces/ecpg/ecpglib/execute.c')
-rw-r--r-- | src/interfaces/ecpg/ecpglib/execute.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c index 5305735f9d1..c2b96f7f16e 100644 --- a/src/interfaces/ecpg/ecpglib/execute.c +++ b/src/interfaces/ecpg/ecpglib/execute.c @@ -398,11 +398,10 @@ ecpg_store_result(const PGresult *results, int act_field, } ecpg_log("ecpg_store_result on line %d: allocating memory for %d tuples\n", stmt->lineno, ntuples); - var->value = (char *) ecpg_alloc(len, stmt->lineno); + var->value = (char *) ecpg_auto_alloc(len, stmt->lineno); if (!var->value) return false; *((char **) var->pointer) = var->value; - ecpg_add_mem(var->value, stmt->lineno); } /* allocate indicator variable if needed */ @@ -410,11 +409,10 @@ ecpg_store_result(const PGresult *results, int act_field, { int len = var->ind_offset * ntuples; - var->ind_value = (char *) ecpg_alloc(len, stmt->lineno); + var->ind_value = (char *) ecpg_auto_alloc(len, stmt->lineno); if (!var->ind_value) return false; *((char **) var->ind_pointer) = var->ind_value; - ecpg_add_mem(var->ind_value, stmt->lineno); } /* fill the variable with the tuple(s) */ |