From: Fabio M. Di Nitto <fdinitto@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 09/19] config: fix possible memory leak in libccs fullxpath usage
Date: Tue, 25 Oct 2011 14:09:00 +0200	[thread overview]
Message-ID: <8f5be849ec7a6da6059f2bc2b3aadc20428654b5.1319544159.git.fdinitto@redhat.com> (raw)
In-Reply-To: <1319544550-18366-1-git-send-email-fdinitto@redhat.com>
Spotted by Coverity Scan
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
---
:100644 100644 6b2e138... 8c4501f... M	config/libs/libccsconfdb/fullxpath.c
 config/libs/libccsconfdb/fullxpath.c |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/config/libs/libccsconfdb/fullxpath.c b/config/libs/libccsconfdb/fullxpath.c
index 6b2e138..8c4501f 100644
--- a/config/libs/libccsconfdb/fullxpath.c
+++ b/config/libs/libccsconfdb/fullxpath.c
@@ -174,10 +174,10 @@ static int dump_objdb_buff(confdb_handle_t dump_handle, hdb_handle_t cluster_han
 int xpathfull_init(confdb_handle_t handle)
 {
 	int size = XMLBUFSIZE;
-	char *buffer, *newbuf;
+	char *buffer;
 	hdb_handle_t cluster_handle;
 
-	newbuf = buffer = malloc(XMLBUFSIZE);
+	buffer = malloc(XMLBUFSIZE);
 	if (!buffer) {
 		errno = ENOMEM;
 		goto fail;
@@ -191,14 +191,9 @@ int xpathfull_init(confdb_handle_t handle)
 	if (confdb_object_find(handle, OBJECT_PARENT_HANDLE, "cluster", strlen("cluster"), &cluster_handle) != CS_OK)
 		goto fail;
 
-	if (dump_objdb_buff(handle, cluster_handle, cluster_handle, &newbuf, &size))
+	if (dump_objdb_buff(handle, cluster_handle, cluster_handle, &buffer, &size))
 		goto fail;
 
-	if (newbuf != buffer) {
-		buffer = newbuf;
-		newbuf = NULL;
-	}
-
 	doc = xmlParseMemory(buffer, strlen(buffer));
 	if (!doc)
 		goto fail;
@@ -214,6 +209,9 @@ int xpathfull_init(confdb_handle_t handle)
 	return 0;
 
 fail:
+	if (buffer)
+		free(buffer);
+
 	return -1;
 }
 
-- 
1.7.4.4
next prev parent reply	other threads:[~2011-10-25 12:09 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-25 12:08 [Cluster-devel] [coverity] config Fabio M. Di Nitto
2011-10-25 12:08 ` [Cluster-devel] [PATCH 01/19] libccs: check return code consistently Fabio M. Di Nitto
2011-10-25 12:08 ` [Cluster-devel] [PATCH 02/19] ccs_config_dump: remove unnecessary pointer to env Fabio M. Di Nitto
2011-10-25 12:08 ` [Cluster-devel] [PATCH 03/19] ccs_tool: improve error checking on ccs_connect Fabio M. Di Nitto
2011-10-25 12:08 ` [Cluster-devel] [PATCH 04/19] libccs: fix error checking Fabio M. Di Nitto
2011-10-25 12:08 ` [Cluster-devel] [PATCH 05/19] configxml: clear variable usage Fabio M. Di Nitto
2011-10-25 12:08 ` [Cluster-devel] [PATCH 06/19] libccs: remove duplicate checks Fabio M. Di Nitto
2011-10-25 12:08 ` [Cluster-devel] [PATCH 07/19] config: fix libccs return codes and errno handling Fabio M. Di Nitto
2011-10-25 12:08 ` [Cluster-devel] [PATCH 08/19] config: improve string error checking in tokenizer Fabio M. Di Nitto
2011-10-25 12:09 ` Fabio M. Di Nitto [this message]
2011-10-25 12:09 ` [Cluster-devel] [PATCH 10/19] config: fix extremely unlikely buffer overflow Fabio M. Di Nitto
2011-10-25 12:09 ` [Cluster-devel] [PATCH 11/19] config: fix a few theoretical buffer overflows Fabio M. Di Nitto
2011-10-25 12:09 ` [Cluster-devel] [PATCH 12/19] config: fix return checks in ldap loader Fabio M. Di Nitto
2011-10-25 12:09 ` [Cluster-devel] [PATCH 13/19] config: make sure error reporting does not overflow buffers Fabio M. Di Nitto
2011-10-25 12:09 ` [Cluster-devel] [PATCH 14/19] " Fabio M. Di Nitto
2011-10-25 12:09 ` [Cluster-devel] [PATCH 15/19] config: fix rng2ldif null reference Fabio M. Di Nitto
2011-10-25 12:09 ` [Cluster-devel] [PATCH 16/19] config: rng2ldif bug fixes Fabio M. Di Nitto
2011-10-25 12:09 ` [Cluster-devel] [PATCH 17/19] config: fix confdb2ldif secure coding Fabio M. Di Nitto
2011-10-25 12:09 ` [Cluster-devel] [PATCH 18/19] config: remove unused var in ccs_tool Fabio M. Di Nitto
2011-10-25 12:09 ` [Cluster-devel] [PATCH 19/19] config: fix a few checks in ccs_tool edit functionalities Fabio M. Di Nitto
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox
  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):
  git send-email \
    --in-reply-to=8f5be849ec7a6da6059f2bc2b3aadc20428654b5.1319544159.git.fdinitto@redhat.com \
    --to=fdinitto@redhat.com \
    /path/to/YOUR_REPLY
  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
  Be sure your reply has a Subject: header at the top and a blank line
  before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).