FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Cluster Development

 
 
LinkBack Thread Tools
 
Old 10-25-2011, 12:09 PM
"Fabio M. Di Nitto"
 
Default config: fix possible memory leak in libccs fullxpath usage

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
 

Thread Tools




All times are GMT. The time now is 10:30 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org