From: Florian Forster Date: Sat, 21 Jan 2012 17:25:37 +0000 (+0100) Subject: Merge branch 'collectd-4.10' into collectd-5.0 X-Git-Tag: collectd-5.0.2^0 X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=26fbc23e518dcc74502ae3b2495112adc3840879;hp=88b1625f74df1e410f05d7acb865b3b06c534bac Merge branch 'collectd-4.10' into collectd-5.0 Change-Id: I8fea9338ac6490b2a76530a58c6bd36ec17d021a --- diff --git a/ChangeLog b/ChangeLog index 9ad049c7..4642da9b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16,6 +16,7 @@ as the hostname, subsequent values in the same network packets could have ended up using the modified name rather than the original name. Thanks to Sebastian Harl for identifying the problem. + * oracle plugin: A memory leak has been fixed in the parameter handling. * python plugin: A memory leak has been fixed. Thanks to Sven Trenkel for fixing this bug! @@ -136,6 +137,7 @@ as the hostname, subsequent values in the same network packets could have ended up using the modified name rather than the original name. Thanks to Sebastian Harl for identifying the problem. + * oracle plugin: A memory leak has been fixed in the parameter handling. * python plugin: A memory leak has been fixed. Thanks to Sven Trenkel for fixing this bug! diff --git a/src/oracle.c b/src/oracle.c index 03567494..ec45996b 100644 --- a/src/oracle.c +++ b/src/oracle.c @@ -1,6 +1,7 @@ /** * collectd - src/oracle.c - * Copyright (C) 2008,2009 Florian octo Forster + * Copyright (C) 2008,2009 noris network AG + * Copyright (C) 2012 Florian octo Forster * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -41,7 +42,7 @@ * affiliates. Other names may be trademarks of their respective owners. * * Authors: - * Florian octo Forster + * Florian octo Forster **/ #include "collectd.h" @@ -91,32 +92,44 @@ static void o_report_error (const char *where, /* {{{ */ sb4 error_code; int status; - status = OCIErrorGet (eh, /* record number = */ 1, - /* sqlstate = */ NULL, - &error_code, - (text *) &buffer[0], - (ub4) sizeof (buffer), - OCI_HTYPE_ERROR); - buffer[sizeof (buffer) - 1] = 0; - - if (status == OCI_SUCCESS) + /* An operation may cause / return multiple errors. Loop until we have + * handled all errors available. */ + while (42) { - size_t buffer_length; + memset (buffer, 0, sizeof (buffer)); + error_code = -1; + + status = OCIErrorGet (eh, /* record number = */ 1, + /* sqlstate = */ NULL, + &error_code, + (text *) &buffer[0], + (ub4) sizeof (buffer), + OCI_HTYPE_ERROR); + buffer[sizeof (buffer) - 1] = 0; + + if (status == OCI_NO_DATA) + return; - buffer_length = strlen (buffer); - while ((buffer_length > 0) && (buffer[buffer_length - 1] < 32)) + if (status == OCI_SUCCESS) { - buffer_length--; - buffer[buffer_length] = 0; - } + size_t buffer_length; - ERROR ("oracle plugin: %s: %s failed: %s", - where, what, buffer); - } - else - { - ERROR ("oracle plugin: %s: %s failed. Additionally, OCIErrorGet failed with status %i.", - where, what, status); + buffer_length = strlen (buffer); + while ((buffer_length > 0) && (buffer[buffer_length - 1] < 32)) + { + buffer_length--; + buffer[buffer_length] = 0; + } + + ERROR ("oracle plugin: %s: %s failed: %s", + where, what, buffer); + } + else + { + ERROR ("oracle plugin: %s: %s failed. Additionally, OCIErrorGet failed with status %i.", + where, what, status); + return; + } } } /* }}} void o_report_error */ @@ -555,11 +568,15 @@ static int o_read_database_query (o_database_t *db, /* {{{ */ &column_name, &column_name_length, OCI_ATTR_NAME, oci_error); if (status != OCI_SUCCESS) { + OCIDescriptorFree (oci_param, OCI_DTYPE_PARAM); o_report_error ("o_read_database_query", "OCIAttrGet (OCI_ATTR_NAME)", oci_error); continue; } + OCIDescriptorFree (oci_param, OCI_DTYPE_PARAM); + oci_param = NULL; + /* Copy the name to column_names. Warning: The ``string'' returned by OCI * may not be null terminated! */ memset (column_names[i], 0, DATA_MAX_NAME_LEN); @@ -737,6 +754,7 @@ static int o_shutdown (void) /* {{{ */ } OCIHandleFree (oci_env, OCI_HTYPE_ENV); + oci_env = NULL; udb_query_free (queries, queries_num); queries = NULL;